我正在尝试更改玫瑰图或“极轴”图上现有图例标题的字体大小。大部分代码都是别人写的,他不在家。我补充道:
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)
谢谢你的帮助
^{} api 接受
pyplot.legend()
的title_fontsize
参数。这里有一个类似的问题: How to set font size of Matplotlib axis Legend?
我设法用第二个答案改变标题的字体大小,我发现这是最简单的答案。也可以更改颜色标题和其他属性。我得到了以下代码:
我的猜测是,可以将任何title属性更改为以下列出的其他参数,以替换set掼fontsize('掼'):
http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.legend
在图例和图例标题中调整字体大小的快速方法:
相关问题 更多 >
编程相关推荐