Skip to content
Advertisement

Total figure width with external legend in matplotlib

I’m using

plt.legend(bbox_to_anchor = (1,1))

to put the legend outside my figure. The journal to which I’m submitting requires specific sizes for the figures. When I use this method, it increases the total width of my figure beyond the required size. I want to have the figure sized exactly to specification. Is there a way to calculate the total width of the figure including the external legend, so that I can reduce my figsize parameter accordingly?

Advertisement

Answer

The following works fine; I’ve just coloured the figure so you can see its size.

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement