如何更改ggplot中的默认美学? [英] How to change default aesthetics in ggplot?
本文介绍了如何更改ggplot中的默认美学?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我更喜欢 geom_point
来使用圆圈( pch = 1
)而不是实心圆点( pch = 16
)。您可以通过将形状
参数传递给 geom_point
来更改标记的形状,例如
Let's say that I would prefer geom_point
to use circles (pch=1
) instead of solid dots (pch=16
) by default. You can change the shape of the markers by passing a shape
argument to geom_point
, e.g.
ggplot(diamonds, aes(depth, carat, colour=cut)) + geom_point(shape=1)
ggplot(diamonds, aes(depth, carat, colour=cut)) + geom_point(shape=16)
如何改变默认行为。
推荐答案
Geom(和stat)默认可以直接更新:
Geom (and stat) default can be updated directly:
update_geom_defaults("point", list(shape = 1))
ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point()
这篇关于如何更改ggplot中的默认美学?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文