【发布时间】:2013-02-01 20:27:21
【问题描述】:
在使用theme_bw 主题时,关闭 Rpy2 中所有网格的正确方法是什么?我知道我可以打开theme_bw,如下:
ggplot2.theme_set(ggplot2.theme_bw(12))
但不确定如何关闭网格。谢谢。
【问题讨论】:
在使用theme_bw 主题时,关闭 Rpy2 中所有网格的正确方法是什么?我知道我可以打开theme_bw,如下:
ggplot2.theme_set(ggplot2.theme_bw(12))
但不确定如何关闭网格。谢谢。
【问题讨论】:
基本上和使用 R 中的 ggplot2 时一样。
这是一个关闭与 X 轴相交的网格的示例。更多“主题化”情节的方法可以在 ggplot2 的文档和教程中找到。
from rpy2.robjects.lib.ggplot2 import ggplot, \
aes_string, \
geom_histogram, \
element_blank, \
theme_bw, \
theme
from rpy2.robjects import r
nogrid_x_theme = theme(**{'panel.grid.major.x': element_blank(),
'panel.grid.minor.x': element_blank()})
iris = r('iris')
p = ggplot(iris) + geom_histogram(aes_string(x = 'Sepal.Width'))
p += theme_bw() + nogrid_x_theme
p.plot()
【讨论】:
p += ... nogrid_x_theme?