我有这样的代码:
import matplotlib.pyplot as plt
from matplotlib.pyplot import *
from matplotlib.font_manager import FontProperties
fontP = FontProperties()
fontP.set_size('xx-small')
fig=plt.figure()
ax1=fig.add_subplot(111)
plot([1,2,3], label="test1")
ax1.legend(loc=0, ncol=1, bbox_to_anchor=(0, 0, 1, 1),
prop = fontP,fancybox=True,shadow=False,title='LEGEND')
plt.show()
Run Code Online (Sandbox Code Playgroud)

从图中可以看出,Fontsize中的设置不会影响Legend Title字体大小.
如何将图例标题的字体大小设置为较小的尺寸?
我正在尝试更改玫瑰或"极地"情节中现有图例的标题字体大小.大多数代码都是由其他人写的,他们不在.我已经添加:-
ax.legend(title=legend_title)
setp(l.get_title(), fontsize=8)
Run Code Online (Sandbox Code Playgroud)
添加标题'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)
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助