在python pylab玫瑰/极坐标图中更改图例标题的字体大小 [英] Changing font size of legend title in Python pylab rose/polar plot

查看:389
本文介绍了在python pylab玫瑰/极坐标图中更改图例标题的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to change the font size of the title of an existing legend on a rose, or 'polar', plot. Most of the code was written by somebody else, who is away. I've added:-

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

添加标题"legend_title",这是用户在使用此代码的其他函数中输入字符串的变量.第二行不返回错误,但似乎也不执行任何操作.完整的代码如下. "Rose"和"RoseAxes"是某人编写的模块/函数.有谁知道改变图例标题字体大小的方法吗?我找到了一些正常图的例子,但找不到玫瑰/极地图的例子.

to add the title 'legend_title', which is a variable that the user enters a string for in a a different function that uses this code. The second line of this doesn't return an error but doesn't appear to do anything either. The complete code is below. 'Rose' and 'RoseAxes' are modules/functions written by somebody. Does anyone know of a way to change the legend title font size? I've found some examples for normal plots but can't find any for rose/polar plots.

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)

感谢您的帮助

推荐答案

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

quick way to adjust font sizes in legend and legend title:

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 pylab玫瑰/极坐标图中更改图例标题的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆