0

enter image description here

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!

Matt
  • 7,255
  • 2
  • 12
  • 34
  • 2
    Please include a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). We don't know how you generated `gg2`, also include example data with `dput` – starja Jul 16 '20 at 12:51
  • It looks like your x-data is continuous. Why are you trying to use a discrete scale? – Roland Jul 16 '20 at 13:14
  • This question is not substantially different than your [previous question](https://stackoverflow.com/q/62490640). – r2evans Jul 16 '20 at 22:57

1 Answers1

0

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))
wurli
  • 2,314
  • 10
  • 17