matplotlib和ggplot - face_grid文本大小标签

时间:2017-03-26 18:07:54

标签: python matplotlib ggplot2 python-ggplot

我在ggplot上使用date的facet_grid函数。

p = ggplot(aes(x='meh',weight='mah',fill='type'),data=plot_df) + geom_bar(stat='identity') + facet_grid('date',scales='fixed') + ggtitle(title)

我使用以下参数成功编辑图例和轴尺寸:

t = theme_gray()
t._rcParams['font.size'] = 30 # Legend font size
t._rcParams['xtick.labelsize'] = 30 # xaxis tick label size
t._rcParams['ytick.labelsize'] = 30 # yaxis tick label size
t._rcParams['axes.labelsize'] = 30 # general label size 

p = p + t

enter image description here

从附图中可以看出,正确的标签(date)几乎不易辨认。

哪个matplotlib参数控制此标签文本大小?我可以看到matplotlib here的自定义选项,但由于facet_grid是一个ggplot函数,我无法看到其中哪一个控制了这个特定的标签。

修改

示例input

import pandas as pd
from ggplot import *

data_df = pd.read_csv("/dir/sample/input/above/tmp.csv")

print data_df.head()

p = ggplot(aes(x='status',weight='duration_proportion',fill='line_name'),data=data_df) + geom_bar(stat='identity') + labs(x="Service status", y="Percentage time") + facet_grid('date',scales='fixed')

t = theme_gray()

t._rcParams['font.size'] = 30 # Legend font size
t._rcParams['xtick.labelsize'] = 30 # xaxis tick label size
t._rcParams['ytick.labelsize'] = 30 # yaxis tick label size
t._rcParams['axes.labelsize'] = 30 

p = p + t

p.save("test.png" ,height=24,width=44)

0 个答案:

没有答案