Strength R will stop printing labels of the reduced axis - for example, 1e + 00 in ggplot2

In ggplot2, how can I stop axis labels shortening - for example. 1e+00, 1e+01 along the x axis after plotting? Ideally, I want to get R to display the actual values, which in this case will be 1,10 .

Any help is greatly appreciated.

+70
r graph ggplot2 axes
Jan 28 '13 at 14:17
source share
4 answers

I think you are looking for this:

 require(ggplot2) df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100)) # displays x-axis in scientific notation p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point() p # displays as you require require(scales) p + scale_x_continuous(labels = comma) 
+92
Jan 28 '13 at 14:23
source share

You tried something like:

 options(scipen=10000) 

before plotting?

+46
Jan 28 '13 at 14:19
source share

Just an update of what @Arun did since I tried it today and it did not work because it was updated for

 + scale_x_continuous(labels = scales::comma) 
+19
Mar 16 '17 at 16:59
source share

As a more general solution, you can use scales::format_format to remove scientific notation. It also gives you a lot of control over exactly how you want your labels to be displayed, unlike scales::comma , which only performs comma-separated orders.

For example:

 require(ggplot2) require(scales) df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100)) # Here we define spaces as the big separator point <- format_format(big.mark = " ", decimal.mark = ",", scientific = FALSE) # Plot it p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point() p + scale_x_continuous(labels = point) 
+7
Nov 28 '17 at 17:34
source share



All Articles