Too many labels on axis

前端 未结 1 964
误落风尘
误落风尘 2021-01-15 06:35

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 si

相关标签:
1条回答
  • 2021-01-15 07:07

    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.

    You should coerce it to be a numeric

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

    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.

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

    0 讨论(0)
提交回复
热议问题