如何在x轴上更改标签?我在轴上有数字,但需要字符。我发现一些日期是
scale_x_date(breaks=datebreaks) + theme(axis.text.x=element_text(angle30, hjust=1)
我尝试过
scale_x_discrete(breaks=c("1","2","3"),labels=c("name1","name2","name3") + thame(axis.text.x=element_text(angle30, hjust=1)
但它不起作用。
答案 0 :(得分:0)
我相信以下内容应允许您通过分别明确声明中断和标签或明确一起声明标签和中断来重新标记x轴上的刻度线:
# Solution 1
p + scale_x_discrete(breaks=c("0.5","1","2"),
labels=c("label 1", "label 2", "label 3"))
# Solution 2 : same plot as solution 1
p + scale_x_discrete(labels=c("0.5" = "label 1", "1" = "label 2",
"2" = "label 3"))