Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The title of a legend in matplotlib can be aligned using the following code:

legend = plt.legend(title="Legend Title", title_align='center')

The title_align parameter can be set to 'center', 'left', or 'right' to adjust the alignment of the legend title. By default, it is set to 'center'.