如何减小绘图中打印的图例框中文本的字体?

发布于 2024-10-15 16:05:13 字数 717 浏览 10 评论 0原文

我试图在一张图中绘制大约 10 个图。我还可以单独放置图例框。但是,我无法减小图例框中字体的大小。任何人都可以建议我减小图例框中字体大小的程序。

我在此给出我所使用的说明:但最终结果并没有受到影响。

# Shink current axis's height by 10% on the bottom
  box = ax.get_position()
  ax.set_position([box.x0, box.y0, box.width * 0.90, box.height])

  # Put a legend to the right of the current axis
  ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), numpoints = 1)
  #plt.show()

  fontP = FontProperties()
  fontP.set_size ('x-small')

  filename1 = "DelayCellSpur"+ str(measuredFrequencyUnderTest)+"MHz.pdf"
  print filename1
  plt.savefig(filename1, dpi = None, facecolor = 'w', orientation = 'portrait',bbox_inches = None)

由于我是新用户,所以无法上传图片。请帮助我减小图例框中字体的大小。 谢谢你, 戈皮

I am trying to plot around 10 plots in a single figure. I also could put the legend box separately. But, I am unable to reduce the size of the font in the legend box. Can anybody suggest me the procedure to reduce the font size in the lengend box.

I am herewith giving the instructions that I have used: But it is not getting affected in the end result.

# Shink current axis's height by 10% on the bottom
  box = ax.get_position()
  ax.set_position([box.x0, box.y0, box.width * 0.90, box.height])

  # Put a legend to the right of the current axis
  ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), numpoints = 1)
  #plt.show()

  fontP = FontProperties()
  fontP.set_size ('x-small')

  filename1 = "DelayCellSpur"+ str(measuredFrequencyUnderTest)+"MHz.pdf"
  print filename1
  plt.savefig(filename1, dpi = None, facecolor = 'w', orientation = 'portrait',bbox_inches = None)

As I am a new user, I am not able to upload the image. Pls help me in reducing the size of the font in the legend box.
Thankyou,
Gopi

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘心安 2024-10-22 16:05:13

你正在使用 matplotlb,不是吗?

像这样的东西可能会有所帮助:

legend_font_props = FontProperties()
legend_font_props.set_size('small')
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), numpoints=1, prop=legend_font_props)

请参阅 http://matplotlib.sourceforge.net/ api/pyplot_api.html#matplotlib.pyplot.legend

You're using matplotlb, aren't you?

Something like this may help:

legend_font_props = FontProperties()
legend_font_props.set_size('small')
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), numpoints=1, prop=legend_font_props)

See http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.legend

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文