3

Suppose you have a plot with multiple lines, e.g.,

plt.plot(np.arange(0, 10, 0.1), np.sin(np.arange(0, 10, 0.1)), label = 'sin')
plt.plot(np.arange(0, 10, 0.1), np.cos(np.arange(0, 10, 0.1)), label = 'cos')
plt.legend()

You will have a plot like

this

However, this may not work well if there are many plots. Is there an elegant way that we could move the legend to teh right of each line plot, with the corresponding color, e.g. the following? example

Mr.cysl
  • 1,494
  • 6
  • 23
  • 37
  • What if the plots end at the same point? How do you want the labels arranged in that case? – Andrew Guy May 21 '19 at 00:17
  • @AndrewGuy Good question. Let's assume they will not appear at exactly the same position. We may loose the constraint a bit more, there will be sufficient space (compared to font size) between each pair of the end pairs. – Mr.cysl May 21 '19 at 00:19
  • This question has been asked several times already. Did you search for solutions? – ImportanceOfBeingErnest May 21 '19 at 00:27

0 Answers0