轴上的标签过多 [英] Too many labels on axis

查看:66
本文介绍了轴上的标签过多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在R中的qplot时遇到了一些麻烦.我正在尝试从数据帧中绘制数据.当我执行下面的命令时,情节在左侧堆积(请参见下图).数据帧只有963行,所以我认为大小不是问题,但是我可以在较小的数据帧上使用相同的命令,看起来不错.有什么想法吗?

I'm having some trouble with qplot in R. I am trying to plot data from a data frame. When I execute the command below the plot gets bunched up on the left side (see the image below). The data frame only has 963 rows so I don't think size is the issue, but I can use the same command on a smaller data frame and it looks fine. Any ideas?

library(ggplot2)
qplot(x=variable,
   y=value,
   data=data,
   color=Classification,
   main="Average MapQ Scores")

或类似地:

ggplot(data = data, aes(x = variable, y = value, color = Classification) +
  geom_point()

推荐答案

您的列value应该是数字时可能是一个因素.这会导致value的每个分类值在y轴上都有自己的输入项,从而产生您所注意到的效果.

Your column value is likely a factor, when it should be a numeric. This causes each categorical value of value to be given its own entry on the y-axis, thus producing the effect you've noticed.

您应该将其强制为数字

data$value <- as.numeric(as.character(data$value))

请注意,可能有充分的理由将其解释为一个因素而不是一个数字,可能是因为它具有一些不是纯数值的条目(可能是1,0001000 m或其中的某些其他字符条目)号码).强制执行的结果可能是信息丢失,因此请予以警告或彻底清除数据.

Note that there is probably a good reason it has been interpreted as a factor and not a numeric, possibly because it has some entries that are not pure numeric values (maybe 1,000 or 1000 m or some other character entry among the numbers). The consequence of the coercion may be a loss of information, so be warned or cleanse the data thoroughly.

此外,您在x轴上似乎也遇到了同样的问题.

Also, you appear to have the same problem on the x-axis.

这篇关于轴上的标签过多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆