2

我试图在一个图中绘制大约 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)

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

4

1 回答 1

2

您正在使用 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

于 2011-01-31T10:28:07.033 回答