Skip to content Skip to sidebar Skip to footer

Text Alignment Using Format In Matplotlib Legend

I'm trying to get two words aligned in a legend in matplotlib. With the print statement I can do this using the tools available to format (< for left alignment, > for right a

Solution 1:

The spacing is correct with the print statement because the font used in the console is monospace. You can replicate this in the legend with:

plt.legend(prop={'family': 'monospace'})

Post a Comment for "Text Alignment Using Format In Matplotlib Legend"