简体   繁体   English

ggplot2:通过在某些标签上添加星号来自定义x轴

[英]ggplot2: customize x-axis by adding an asterisk to some of the labels

Using the built in R dataset ToothGrowth 使用内置的R数据集ToothGrowth

ggplot(ToothGrowth, aes(x=dose,y=len,colour=supp)) +
  geom_point()

Is there a way to add an asterisk to some of the x-axis labels? 是否可以在某些X轴标签上添加星号? For instance 1.0 and 2.0? 例如1.0和2.0?

How about: 怎么样:

 library(ggplot2)
  ggplot(ToothGrowth, aes(x=dose,y=len,colour=supp)) +
    geom_point() + scale_x_continuous(breaks = seq(0.5, 2, 0.5),
                                      ,labels = c("0.5","1*","1.5", "2*"))

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM