where y1 and y2 are two vectors sharing the same x values. But legend() does not provide **1. Automatic detection of elements to be shown in the legend**: it only produces a small square in the top right corner. likewise ax.legend or legend(loc="upper right").
Thank you
As explained in the docs, legend() only works if you pass label= to plot or explicitly call set_label. Otherwise, you need to pass the desired legends to legend, e.g.:
Thank you, legend(["first line", "second line"]) worked. And yes, I am using Pyplot. But I did not understand the syntax to place the label directly in the plot call:
In Python, a string can be either double- or single-quoted ("foo" or 'foo'), for reasons I don’t comprehend. In Julia, strings mustuse double quotes. Single quotes are used for literals 'x' of the character typeChar (Python doesn’t have a character type).