Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201867

How can I change axis labels from scientific format to power format using ggplot2 and scales?

$
0
0

I'm creating a chart in ggplot and want to change my x-axis ticks from scientific format to 10^n, 20^n, 30^n etc format without changing my axis to a log scale. I've copied code from the comments section in this thread:

How can I format axis labels with exponents with ggplot2 and scales?

And slightly altered it to this:

scale_x_continuous(label= function(x) {ifelse(x==0, "0", parse(text=gsub("[+]", "", gsub("e", "^", scientific_format()(x)))))} )

This gives me tick axis labels in the form 1^n, 2^n, 3^n etc. Is there any way to change this to 10^n, 20^n, 30^n etc (n-1 obviously)?

Many thanks.


Viewing all articles
Browse latest Browse all 201867

Trending Articles