简体   繁体   English

Matplotlib恼人的正方形在右上角

[英]Matplotlib annoying square in right top corner

May be this is a silly question. 可能这是一个愚蠢的问题。 I am exporting an eps plot from matplotlib (installed through Anaconda in Ubuntu 18.04 LTS). 我正在从matplotlib导出eps图(通过在Ubuntu 18.04 LTS中的Anaconda安装)。 When opening the .eps file an annoying square appears at the right top corner, this seems to be something from the fig viewer. 当打开.eps文件时,右上角会出现一个令人讨厌的正方形,这似乎是无花果浏览器的特征。 I still could not manage to find a solution. 我仍然无法找到解决方案。

在此处输入图片说明

EDIT: I am adding the code, after the accepted answer. 编辑:在接受的答案后,我正在添加代码。

plt.figure(num=2, figsize=(5,3))
p1, = plt.plot(ffaa[0], ffaa[1], 'k-', linewidth=0.5) 
plt.xlabel('Time (s)',   fontsize=8)
plt.ylabel('Voltage (V)',fontsize=8)
plt.legend(handles=[p1]) 
plt.xlim([0,100])
plt.show()
mu.figexp('Figure 03 - Frequency spectrum', plt)

The "annoying square" is a legend . “烦人的广场”是一个legend So at some place in your code you create a legend for your graph, presumably via plt.legend() or ax.legend() . 因此,可以在代码的某个位置为图形创建图例,大概是通过plt.legend()ax.legend() However your plot does not have any label associated with it. 但是,您的图没有任何关联的标签。 Hence the legend stays empty. 因此,图例保持为空。

Solutions: 解决方案:

  • Remove the line that created the legend from your code. 从代码中删除创建图例的行。
  • Add a label to your plot, eg via plt.plot(...., label="my label") , which would then be shown inside the box. 将标签添加到绘图中,例如通过plt.plot(...., label="my label") ,然后将其显示在框内。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM