1

I want to change the format of the numbers in my y axis from n000 to nk, where n is a number from 1 to 10 and k is just "k" and its only function is to replace 3 zeros. Why? To save some space. My code is:

x <- seq(1:10)
y <- c(0, 500, 1000, 5000, 10000, 13000, 8000, 4000, 1000, 200) 
df <-data.frame(x, y)
library(ggplot2)
ggplot(df, aes(x, y)) +
  geom_bar(stat="identity", fill="white", colour="black") +
  xlab("X (%)") +
  ylab("Número de estructuras") +
  theme_bw()

Thanks

coip
  • 1,312
  • 16
  • 30
murpholinox
  • 639
  • 1
  • 4
  • 14
  • Look at _trans_new_ in the [scales package](http://www.inside-r.org/packages/cran/scales/docs/trans_new) to create your own transformation, say "my_trans". You can apply your transformation to the plot by adding _scale_x_continuous(trans = my_trans())_ – Biswajit Banerjee May 14 '16 at 05:32
  • 1
    A duplicated question. Sorry! The answer in http://stackoverflow.com/questions/13973644/si-prefixes-in-ggplot2-axis-labels worked for 5000 to became 5k but 10000 gave NANA. The function in the answer in this question http://stackoverflow.com/questions/21045545/how-to-accurately-display-si-prefix-for-numbers-in-y-axis-scale-of-plot-made-wit produces the desired output (5k 10k) – murpholinox May 14 '16 at 06:16

0 Answers0