0

This is my barplot

ggplot( diamonds, aes(clarity , price) ) +
      geom_bar(stat = "identity")

and I get this as my output enter image description here

I am not able to convert the Y axis exponential display to regular numbers

Do not want scientific notation on plot axis

I have tried the scipen and format function as well

ggplot( diamonds, aes(clarity , b) , options(scipen=10)) +
  geom_bar(stat = "identity")

b <- diamonds$price
formatC(b , format = "d")

a <- ggplot( diamonds, aes(clarity , b)) +
  geom_bar(stat = "identity")

This is not a duplicate so kindly don't mark as duplicate as i have tried all the other options I came accross. Please help if I am making any mistake or suggest an answer.

anotherfred
  • 1,330
  • 19
  • 25
Sovik Gupta
  • 147
  • 2
  • 13
  • It *is* a duplicate. Your mistake was not searching for ggplot - the answer you linked is for base r. Try https://stackoverflow.com/a/14564102/5316882 – anotherfred Apr 17 '18 at 15:24
  • Does `ggplot` take an argument `options`? I always assumed that that option went on the *outside* (which worked for me). @anotherfred's link is your key, I think, and it can be a nice trick to assign a custom function to `scale_y_continuous(..., labels=myfunc)` where your `myfunc` makes it look exactly the way you want. (Well-asked question, btw ... though it does use `b` before it is defined.) – r2evans Apr 17 '18 at 15:26

1 Answers1

3

I would suggest:

ggplot( diamonds, aes(clarity , price) ) +
    geom_bar(stat = "identity") +
    scale_y_continuous(labels = scales::comma) 
Alex Dometrius
  • 812
  • 7
  • 20