I am trying to make automated plots with matplotlib, with several different features plotted on top of one another (the background is a filled contour plot, one level above is a pcolormesh). The topmost feature that I'm trying to plot is several scatter plots, with different labels and icons.
I'm trying to add a legend to this plot, currently using the following commands:
leg = ax.legend(legplots,
legnames,
scatterpoints=1,
loc='upper center',
ncol=3,
fontsize=14,
bbox_to_anchor=(0.5, -0.14),
fancybox=True, shadow=True)
Assume that ax is the main axes, and that legplots and legnames are lists of scatter plots and their appropriate labels respectively.
Adding the legend works correctly, but as the number of legplots that I have (and their name lengths) vary, as you animate the plots, the legend grows and shrinks in size. How do I control the size of the legend box and the column widths inside the legend? Is this possible?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…