[英]How do I make the y-axis intersect the x-axis at 0 in ggplot2?
So when I make plots sometimes I see the y crossing x at some offset. 因此,当我制作情节时,我会看到y交叉x处于某个偏移处。 I generated this figure using:
我使用以下方法生成此图:
ggplot(data=d2,aes(y=log10(Nems+1),x=Time)) +
geom_point(size=3,shape=1) +
geom_line(data=d2,aes(x=time_model,y=log10(value),group=variable,linetype=variable)) +
ylim(0.001,2) + no_bg + draw_axis
I end up manually moving the y in Illustrator. 我最终在Illustrator中手动移动y。 Is there a way to just do it here?
有没有办法在这里做到这一点?
alt text http://img816.imageshack.us/img816/7633/testzh.png alt text http://img816.imageshack.us/img816/7633/testzh.png
Here is another solution: 这是另一个解决方案:
... + scale_x_continuous(expand=c(0,0))
See also this related question: Margin adjustments when using ggplot's geom_tile()
另请参阅此相关问题: 使用ggplot的
geom_tile()
时的边距调整
Try adding this to your plot: + coord_cartesian(xlim = c(0, 90))
尝试将此添加到您的情节:
+ coord_cartesian(xlim = c(0, 90))
That should limit the x-axis to 0 through 90. 这应该将x轴限制为0到90。
You could also do + xlim(0, 90)
, which has a similar effect - but also removes any data outside of its bounds from the dataset. 您也可以执行
+ xlim(0, 90)
,它具有类似的效果 - 但也会从数据集中删除其边界之外的任何数据。 That can be problematic if you're trying to zoom in on features of geoms that should be calculated using the whole dataset (eg, smooths) because it recalculates those geoms based only on what's inside the limits. 如果你试图放大应该使用整个数据集计算的geom的特征(例如,smooths),这可能会有问题,因为它只根据限制内的内容重新计算这些geom。 coord_cartesian() calculates all the geoms from the full dataset, then limits the window to what you specify.
coord_cartesian()从完整数据集计算所有geom,然后将窗口限制为您指定的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.