0

+ theme_whatever()python ggplot 从哪里获取其默认值,如何更改它们以便在每次创建绘图时都无需使用?

4

1 回答 1

4

我假设您指的是ggplot来自http://ggplot.yhathq.com/的包?似乎没有任何等效于 R 包的theme_set功能ggplot2,默认主题目前被硬编码为theme_grey(). 我认为你能做的最好的就是在一个地方定义你的主题并在所有情节中使用它:

from ggplot import *
my_theme = theme_seaborn()
p = ggplot(aes(x='wt', y='mpg'), data=mtcars) + geom_point()
print(p + my_theme)
p2 = ggplot(aes(x='date', ymin='beef - 1000',
            ymax='beef + 1000'), data=meat) + geom_area()
print(p2 + my_theme)

或者,您可以为自己定义一个您调用的小型包装函数,而不是print(... + my_theme)调用。

于 2015-01-06T15:07:44.960 回答