Matplotlib: put legend symbols to the right of shortcuts

This is a simple thing, but I have been looking for quite some time: I want to customize the shape legend by changing the horizontal order of characters and labels.

In Gnuplot, this is achieved simply by using a key . Example: change x data1 to data1 x . There does not seem to be a user-friendly solution in matplotlib. So, I thought about changing the kind of descriptor binding or just moving the handle position, but I could not find any point to start.

+7
python matplotlib legend
source share
1 answer

The requested function already exists as the markerfirst of the legend command.

  plt.plot([1,2],[3,4], label='labeltext') plt.legend(markerfirst=False) plt.show() 

If you want to do this by default, you can change the legend.markerfirst value in rcParams , see matplotlib setting .

+3
source share

All Articles