原文链接:http://www.juzicode.com/archives/2486
错误提示:
使用matplotlib legend提示:ValueError: Unrecognized location ‘upper’. Valid locations are
Traceback (most recent call last):
File "09-plt-step.py", line 30, in <module>
plt.legend(title='参数where:',fontsize='xx-small',loc='upper')
File "D:\Python\Python38\lib\site-packages\matplotlib\pyplot.py", line 2738, in legend
return gca().legend(*args, **kwargs)
File "D:\Python\Python38\lib\site-packages\matplotlib\axes\_axes.py", line 417, in legend
self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
File "D:\Python\Python38\lib\site-packages\matplotlib\legend.py", line 455, in __init__
raise ValueError(
ValueError: Unrecognized location 'upper'. Valid locations are
best
upper right
upper left
lower left
l

本文介绍了在使用Matplotlib绘制图表时遇到的一个常见问题——设置图例位置时出现的错误,并给出了正确的图例位置参数及其解决方案。
最低0.47元/天 解锁文章
31万+





