【发布时间】:2012-06-12 09:56:00
【问题描述】:
我正在尝试更改玫瑰图或“极地”图上现有图例标题的字体大小。大部分代码是由不在场的其他人编写的。我添加了:-
ax.legend(title=legend_title)
setp(l.get_title(), fontsize=8)
添加标题“legend_title”,这是一个变量,用户在使用此代码的不同函数中输入字符串。第二行没有返回错误,但似乎也没有做任何事情。完整的代码如下。 'Rose' 和 'RoseAxes' 是由某人编写的模块/函数。有谁知道改变图例标题字体大小的方法?我找到了一些正常情节的例子,但找不到玫瑰/极地情节的例子。
from Rose.RoseAxes import RoseAxes
from pylab import figure, title, setp, close, clf
from PlotGeneration import color_map_xml
fig = figure(1)
rect = [0.02, 0.1, 0.8, 0.8]
ax = RoseAxes(fig, rect, axisbg='w')
fig.add_axes(ax)
if cmap == None:
(XMLcmap,colors) = color_map_xml.get_cmap('D:/HRW/VET/HrwPyLibs/ColorMapLibrary/paired.xml',255)
else:
XMLcmap = cmap
bqs = kwargs.pop('CTfigname', None)
ax.box(Dir, U, bins = rose_binX, units = unit, nsector = nsector, cmap = XMLcmap, lw = 0, **kwargs )
l = ax.legend()
ax.legend(title=legend_title)
setp(l.get_texts(), fontsize=8)
setp(l.get_title(), fontsize=8)
感谢您的帮助
【问题讨论】:
-
对于任何感兴趣的人,我们将其更改为使其工作:l= ax.legend(title=legend_title) setp(l.get_texts(), fontsize=12) setp(l.get_title (), 字体大小=12)
标签: python title font-size legend matplotlib