gpt4 book ai didi

python - 在 Python pylab rose/polar plot 中更改图例标题的字体大小

转载 作者:太空狗 更新时间:2023-10-29 20:46:13 26 4
gpt4 key购买 nike

我正在尝试更改玫瑰图或“极地”图上现有图例标题的字体大小。大多数代码是由不在的其他人编写的。我添加了:-

ax.legend(title=legend_title)
setp(l.get_title(), fontsize=8)

添加标题“legend_title”,这是一个变量,用户可以在使用此代码的不同函数中为其输入字符串。第二行没有返回错误,但似乎也没有做任何事情。完整代码如下。 “Rose”和“RoseAxes”是某人编写的模块/函数。有谁知道更改图例标题字体大小的方法?我找到了一些正常图的例子,但找不到玫瑰图/极 map 的例子。

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)

感谢您的帮助

最佳答案

调整图例和图例标题字体大小的快速方法:

import numpy as np
import pylab as plt

f,ax = plt.subplots()
x = np.arange(10)
y = np.sin(x)
ax.plot(x,y, label = 'sin')

leg = ax.legend(fontsize = 'large')
leg.set_title("title", prop = {'size':'x-large'})

f.show()

关于python - 在 Python pylab rose/polar plot 中更改图例标题的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10947167/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com