使scale_y_log10的刻度为0.01,0.1,1 [英] Make scale_y_log10 to have the tickmarks at 0.01,0.1,1
问题描述
我写了下面的代码来制作情节
pd < - position_dodge(.2)##将它们移动.05 (数据,aes(x = CombSEG,y = conc,shape = A,color = A,lty = A,group = A))+
geom_point ()+
geom_line()+
geom_errorbar(aes(ymin = conc-se,ymax = conc + se),
width = .1,position = pd)+
theme_bw()+
limits(c(0
)scale_y_log10(breaks = c(0.01,0.1,1),labels = c(0.01,0.1,1))
自动缩放比例为10 ^ -1.8,10 ^ -1.6,10 ^ -1.4 ... 10 ^ -0.4。就像最低的勾号为0.01,最高的勾号为1.
感谢您的帮助。
编辑:下面是我试过你的代码后的情节:
breaks 和标签 code> scale_y_的参数log10
(请阅读此处)。 #组成一些样本数据
df < - data.frame(x = 1:100,y = 10 ^ - ( 2 * runif(100)))
ggplot(df,aes(x = x,y = y))+ geom_point()+ scale_y_log10()
看起来像:
然后,要修改log10比例以在.01,.1和1处定制中断,请使用 breaks
参数:
ggplot(df,aes(x = x,y = y))+ geom_point()+ scale_y_log10 = c(.01,.1,1))
看起来像:
标签
参数:
ggplot(df,aes(x = x,y = y))+ geom_point()+
scale_y_log10(break s = c(.01,.1,1),labels = c(.01,.1,1))
I wrote the following code to make the plot
pd<- position_dodge(.2) # # move them .05 to the left and right
pm25 <- ggplot(data, aes(x=CombSEG, y=conc,shape=A,color=A, lty=A, group=A)) +
geom_point() +
geom_line() +
geom_errorbar(aes(ymin=conc-se, ymax=conc+se),
width=.1, position=pd) +
theme_bw()+
limits(c(0
scale_y_log10(breaks=c(0.01,0.1,1),labels=c(0.01,0.1,1))
The automatic scale breaks are 10^-1.8, 10^-1.6, 10^-1.4 ... 10^-0.4. I would actually like the lowest tick to be 0.01 and the highest tickmark is 1.
Thank you for your help.
Edits: Here is what the plot look like after I tried your code.
解决方案 Use the breaks
and labels
arguments of scale_y_log10
(read about them here).
# make up some sample data
df <- data.frame(x=1:100,y=10^-(2*runif(100)))
ggplot(df,aes(x=x,y=y)) + geom_point() + scale_y_log10()
Looks like:
Then to modify the log10 scale to have custom breaks at .01, .1 and 1, use the breaks
argument:
ggplot(df,aes(x=x,y=y)) + geom_point() + scale_y_log10(breaks=c(.01,.1,1))
Looks like:
Finally, if you want the labels to also be 0.1, .1 and 1, use the labels
argument:
ggplot(df,aes(x=x,y=y)) + geom_point() +
scale_y_log10(breaks=c(.01,.1,1),labels=c(.01,.1,1))
这篇关于使scale_y_log10的刻度为0.01,0.1,1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!