2017-09-05 108 views
1

Folk,ggplot in python:plot size and color

我想在python中使用ggplot。

from ggplot import * 
ggplot(diamonds, aes(x='price', fill='cut')) + geom_density(alpha=0.25) + facet_wrap("clarity") 

夫婦的事情,我要做的:

1)我預計在這兩個充滿了色彩和線條,但你可以看到的顏色都是灰色

2)我正在調整劇情的大小。在R我會運行此之前的情節:

options(repr.plot.width=12, repr.plot.height=4) 

但是,這不起作用。

有沒有人知道我是如何在分佈中着色並且還改變了大小?

謝謝。當前輸出已附加。

enter image description here

回答

1

顏色

使用color代替填充。 例如;

from ggplot import * 
ggplot(diamonds, aes(x='price', color='cut')) + geom_density(alpha=0.25) + facet_wrap("clarity") 

尺寸

一對夫婦的方式來做到這一點。

最簡單的就是ggsave - 查閱文檔。

或者,使用themeplot_margin說法:

ggplot(...) ... + theme(plot_margin = dict(right = 12, top=8)) 

或者,使用matplotlib設置:

import matplotlib as mpl 
mpl.rcParams["figure.figsize"] = "11, 8" 
ggplot(...) + ... 

希望這有助於!

+1

顏色有助於確定,尺寸需要一些修補,但仍然解決了我的問題。我不配!我不配!我不配! –