只设置ggplot限制的下限 [英] set only lower bound of a limit for ggplot

查看:133
本文介绍了只设置ggplot限制的下限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以只设定连续比例的下限?我想让所有我的地块为基础而不需要指定上限。

eg

  + scale_y_continuous(minlim = 0)


解决方案

您可以使用 expand_limits $ b $ pre $ g $ p $ ggplot(mtcars,aes(wt,mpg))+ geom_point()+ expand_limits(y = 0)

以下是两者的对比:


  • 没有 expand_limits






  • expand_limits





从1.0.0版本的 ggplot2 ,你只能指定一个限制,就像通常将第二个限制设置为 NA 一样。这种方法将允许扩展和截断轴范围。

  ggplot(mtcars,aes(wt,mpg))+ geom_point()+ 
scale_y_continuous(limits = c(0,NA))

ylim(c(0,NA))指定它给出了一个相同的数字。

Is it possible to only set the lower bound of a limit for continuous scale? I want to make all my plots 0 based without needing to specify the upper limit bound.

e.g.

+ scale_y_continuous(minlim=0)

解决方案

You can use expand_limits

ggplot(mtcars, aes(wt, mpg)) + geom_point() + expand_limits(y=0)

Here is a comparison of the two:

  • without expand_limits

  • with expand_limits

As of version 1.0.0 of ggplot2, you can specify only one limit and have the other be as it would be normally determined by setting that second limit to NA. This approach will allow for both expansion and truncation of the axis range.

ggplot(mtcars, aes(wt, mpg)) + geom_point() +
  scale_y_continuous(limits = c(0, NA))

specifying it via ylim(c(0, NA)) gives an identical figure.

这篇关于只设置ggplot限制的下限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆