如何在qplot()中自定义x轴上的值?

时间:2014-05-19 05:17:35

标签: r ggplot2

我正在使用qplot以下代码。

 qplot(topN, F1Score, data = evaluation.data, geom = c("point", "line"), color= Recommender, main = "F1 score...")

x轴为topN,y轴为F1Score。 x轴应该只包含整数值。但是如图所示,有小数位数。 如何自定义此选项以仅使用整数值? enter image description here

1 个答案:

答案 0 :(得分:2)

您可以使用breaks中的scale_x_continuous参数。

qplot(topN, 
      F1Score, 
      data = evaluation.data, 
      geom = c("point", "line"), 
      color= Recommender, 
      main = "F1 score...") + 
  scale_x_continuous(breaks=c(5, 10, 15))

此外,您的色彩指南似乎并不十分有用。我可能会删除传说。

+ scale_color_discrete(guide="none")