Customize axis labels

匿名 (未验证) 提交于 2019-12-03 01:58:03

问题:

I have a simple geom_point plot, in which the x variable is ordinal, taking 5 values (coded 1:5).

In the plot I would like to replace it with 5 corresponding text labels. Is it possible to do it in ggplot?

回答1:

You should be able to do this with scale_x_discrete.

library(ggplot2) df 


回答2:

scale_x_discrete should do it:

x 


回答3:

Here is a reproducible example I think encapsulates your Q (?):

require(ggplot2) dat 

It isn't immediately clear what data you have, but if you mean something like this:

(p1 

Then I think you want a stripchart, which can be achieved in ggplot via a factor

dat2 

If this isn't what you mean, can you edit your Q to provide an example?



文章来源: Customize axis labels
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!