I'm trying to plot graphs in spyder but every line in my code starts a new plot. I've tried using the example from one of the python tutorials whose code I'm including and the same happens.
import matplotlib.pyplot as plt
x = [1,2,3]
y = [5,7,4]
x2 = [1,2,3]
y2 = [10,14,12]
plt.plot(x, y, label='First Line')
plt.plot(x2, y2, label='Second Line')
plt.xlabel('Plot Number')
plt.ylabel('Important var')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
Each line produces a new plot instead of adding to the first one. So plt.xlabel gives a new empty plot with an x label instead of adding an x label to the original plot, plt.ylabel does the same and so on.
This is probably a stupid question but I'd really appreciate any help.picture of plots
