如何使用以离散的方式将标签间隔分配给x轴刻度?

时间:2015-05-20 06:34:02

标签: r plot ggplot2

数据框如下所示:

    > head(melted_sensors_ovens_df)
         macid               variable value
1 D828C9012DB2 ERDx5205.DISPLAY_TIMER     1
2 D828C9011393 ERDx5205.DISPLAY_TIMER     2
3 D828C9014C85 ERDx5205.DISPLAY_TIMER     3
4 D828C90121FE ERDx5205.DISPLAY_TIMER     4
5 D828C90139EE ERDx5205.DISPLAY_TIMER     5
6 D828C901551F ERDx5205.DISPLAY_TIMER     6

我使用以下命令绘制了数据:

ggplot(melted_sensors_ovens_df[order(melted_sensors_ovens_df$value), ], 
       aes(variable, value, colour=variable)) + 
    geom_point() +
    labs(x="Sensors", y="Present / Absent in each Oven", title="") + 
    scale_x_discrete(breaks=seq(0, 10, 0.25), labels=as.character(seq(0, 10, 0.25))) + 
    theme(legend.position = "none", 
          axis.text.x = element_blank(), 
          axis.title.x = element_text(size=40), 
          axis.title.y = element_text(size=40))

输出图像如下所示: enter image description here

现在x轴实际上是149个传感器的列表,我无法分配,因为它会有点乱。我想知道如何分配标签S1,S30,S60,S90等(即以某个间隔的标签)。怎么做到这一点?我在考虑使用scale_x_discrete()还是有其他方法吗?

0 个答案:

没有答案