5

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!

cs0815
  • 16,751
  • 45
  • 136
  • 299

2 Answers2

10

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

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

AntoniosK
  • 15,991
  • 2
  • 19
  • 32
4

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.

Agile Bean
  • 6,437
  • 1
  • 45
  • 53