Matplotlib:figlegend仅打印第一个字母 [英] Matplotlib: figlegend only printing first letter
本文介绍了Matplotlib:figlegend仅打印第一个字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试只打印一行图,但是我只得到第一个字母.我有以下脚本用于制作情节:
I try to print a figlegend with only one line, but I only get the first letter. I have the following script for making the plot:
from pylab import *
k = plot((0, 1),(1, 1))
figlegend((k),('Limit'),loc='lower center')
savefig('test.pdf')
输出为:
我做错了什么? (或者是一个错误?)
What am I doing wrong? (Or is it a bug?)
推荐答案
我还没有弄清楚matplotlib中是bug还是故意的(出于某种原因),但是为了获得完整的图例标签,您需要在标签列表上留下逗号:
I haven't figured out whether it is a bug or intentional (for some reason) in matplotlib, but in order to get a full legend label you need to leave a trailing comma on your list of labels:
figlegend((k),('Limit',),loc='lower center')
更改该行和您的代码:
from pylab import *
k = plot((0, 1),(1, 1))
figlegend((k),('Limit',),loc='lower center')
savefig('test.pdf')
产生图形:
或者,可以使用[]
获得相同的结果:
Alternatively, one can use []
to achieve the same result:
figlegend((k),(['Limit']),loc='lower center')
这篇关于Matplotlib:figlegend仅打印第一个字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文