关闭rpy2中的ggplot2栅格

2024-04-26 11:46:34 发布

您现在位置:Python中文网/ 问答频道 /正文

在使用theme_bw主题时,关闭Rpy2中所有网格的正确方法是什么?我知道我可以按如下方式打开theme_bw

ggplot2.theme_set(ggplot2.theme_bw(12))

但不知道如何关闭电网。谢谢。在


Tags: 方法网格主题方式电网themebwset
1条回答
网友
1楼 · 发布于 2024-04-26 11:46:34

它基本上是用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()

相关问题 更多 >