Reputation: 23
I have created a plot with ggplot
, but the numbers on the axes are not formatted as I want them.
Here's my code:
ggplot() +
geom_line(data = data1, aes(f, fsu), color = "green") +
geom_line(data = data2, aes(f, fsu), color = "black") +
geom_line(data = data.ref, aes(f, fsu), color = "red") +
scale_x_log10(limits = c(10^-4, 10)) +
scale_y_log10() +
labs(x = "f", y = "fS_u") +
theme_minimal()
I want the values on x and y axis that looks like this: "1e-01, 1e-02" to look like instead like: "10¹ 10² 10³"
I tried to put
scale_x_log10(limits = c(10^-4, 10), scales = label_scientific())
Upvotes: 2
Views: 72
Reputation: 226182
Adapting this question, I think you want:
df <- data.frame(x = 10^(-1:-5), y = 1:5)
library(ggplot2)
ggplot(df, aes(x = x, y = y)) +
geom_point() +
scale_x_log10(labels=scales::label_log())
## thanks to @stefan in comments.
## Was: trans_format("log10", scales::math_format(10^.x))
Upvotes: 3