简体   繁体   中英

in R, my x-axis label does not appear and how to add it?

在此处输入图像描述

As you can see in the attached graph I plotted, the labels on X-Axis are missing. I checked some methods and can not figure out how to add the labels. Actually, I want to add the labels of $500,$1000,$2000,$5000,$10000,$20000 on X-Axis. Could you give advice on this? (Please note my labels are not equally distancing) Below is part of codes FYI:

gg3 <- gg2 +
  theme(legend.position="top",legend.direction = "horizontal") +
  guides(size = FALSE) +
  theme(legend.title = element_blank())

gg4 <- gg3 +
  scale_x_discrete(breaks=c("500","1000","2000","5000","10000","20000"))

Thank you!

A sample of your data would help here. However you may want to try this:

gg4 <- gg3 +
  scale_x_continuous(breaks = c(500, 1000, 2000, 5000, 10000, 20000),
                     labels = function(breaks) paste0("$", breaks))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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