4

This:

ggplot(Data, aes(x = Bla), bins = 30, labels = TRUE, format(x, scientific = FALSE)) +
    geom_histogram()

does not work. I want to suppress the scientific notation (e.g. 1.0e+07). Any ideas? Thanks!

4
  • 1
    How about a working example?
    – hrbrmstr
    Oct 11, 2018 at 10:59
  • 1
    You can see this answer: stackoverflow.com/questions/11610377/… The idea being that you can use the scales package to reformat the labels of your axes.
    – Rekyt
    Oct 11, 2018 at 11:04
  • 2
    You can use options(scipen = 999) before you plot
    – AntoniosK
    Oct 11, 2018 at 11:04
  • Thanks @AntoniosK it does the trick - if ok please post answer
    – cs0815
    Oct 11, 2018 at 11:26

2 Answers 2

Reset to default

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

8

You can use options(scipen = 999) before you plot.

This will disable scientific notation in general and not only in your x-axis.

1

There are a couple of options apart from options(scipen = 999) which you may want to avoid if you don't want set this for all charts.

ggplot(Data, aes(x = Bla), bins = 30) +
  geom_histogram() +
  scale_x_continuous(labels = ~ format(.x, scientific = FALSE))

or

ggplot(Data, aes(x = Bla), bins = 30) +
  geom_histogram() +
  scale_x_continuous(labels = scales::comma)

Instead of scales::comma, the scales packages also offers

  • scales::label_number()
  • scales::label_dollar()
  • scales::label_date()

which are handy if you have financial data or dates.

Not the answer you're looking for? Browse other questions tagged or ask your own question.