我使用的是squarify
包在python,codeLink,绘制treemap
,wikiTreemapArticle。在此基础上example,我可以产生一个树形图,但我无法看到如何在广场标签的fontsizes可以修改。在脚本的基本路线是:
ax = squarify.plot(countryPop, color=colors, label=labels, ax=ax, alpha=.7)
在这里,我不能添加“字号”属性。我将如何改变标签的尺寸?
在squarify
工作在matplotlib
pyplot
那么你只需要改变pyplot
的德字号。
我用做我的绘图代码以后的事。
SMALL_SIZE = 13
MEDIUM_SIZE = 18
BIGGER_SIZE = 23
plt.rc('font', size=MEDIUM_SIZE) # controls default text sizes
plt.rc('axes', titlesize=BIGGER_SIZE) # fontsize of the axes title
plt.rc('axes', labelsize=BIGGER_SIZE) # fontsize of the x and y labels
plt.rc('xtick', labelsize=MEDIUM_SIZE) # fontsize of the tick labels
plt.rc('ytick', labelsize=MEDIUM_SIZE) # fontsize of the tick labels
plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title
这样你就可以改变你的情节任何字体,包括squarify
treemap
情节。
更新:现在有改变通过text_kwargs参数的字体大小(squarify == 0.3.0或更高版本)的可能性:
ax = squarify.plot(countryPop, color=colors, label=labels, ax=ax, bar_kwargs={'alpha':.7}, text_kwargs={'fontsize':10})