我有一些数据正在绘制,如下所示:
g <- ggplot(datapile, aes(x = Re, y = CD))
g <- g + geom_line(data = datapile, linetype = "solid", size = 1)
g <- g + scale_y_continuous(trans='log10', limits = c(0.01, 400), n.breaks = 20)
g <- g + scale_x_continuous(trans='log10', limits = c(0.02, 1e7), n.breaks = 20)
g <- g + ylab(expression(Drag~Coefficient*","~C[D]))
g <- g + xlab(expression(Reynolds~Number*","~frac(rho~V~d, mu)))
g
有人知道这个吗?
brks <- c(c(1,2,4,6,8) %o% 10^(0:10))
# using a trick from https://stackoverflow.com/a/23902261/6851825
labs <- if_else(log10(brks) == floor(log10(brks)),
paste0("\n10^", log10(brks)),
paste(brks / 10^floor(log10(brks))))
ggplot(mtcars, aes(wt^5, mpg^3)) +
geom_point() +
scale_x_log10(guide = "axis_logticks",
breaks = brks, minor_breaks = NULL,
labels = labs)