Reputation: 1982
Is there a way in matplotlib to position the text in legend to the right of the line styles?
That is, I want a legend that looks like this
Thanks
Upvotes: 3
Views: 310
Reputation: 339550
As seen from the legend
documentation, there is a markerfirst
argument which can be set to False to make the markers appear last.
plt.legend(markerfirst=False)
Full example:
import matplotlib.pyplot as plt
for i in range(3):
plt.plot([1,2,3],[3-i, i/3., i], marker="o",label="label {}".format(i))
plt.legend(markerfirst=False)
plt.show()
Upvotes: 2