When I am executing the below code, I can see the Demo
is printing at the top horizontally. The Demo2
prints inside the plot with dotted line
. But I can't see theDemo1
?
Why Demo1
is not printing and why Demo
is coming top horizontally?
import matplotlib.pyplot as plt
x = [1,2,3,4,5,-1-2]
y = [-1,5, 100, -2, 50, 100]
t = [100, 110, 120, 130, 140, 150]
plt.figure()
ax1 = plt.subplot(3, 1, 1)
plt.title('Demo');
ax1.plot(t,x, 'b.:', label="Demo") # Showing top Horizontal
ax2 = plt.subplot(3, 1, 2, sharex=ax1)
ax2.plot(t,y, 'b.:', label="Demo1") # Not showing up
ax3 = plt.subplot(3, 1, 3, sharex=ax1)
ax3.plot(t,t, 'b.:', label="Demo2") # This is perfect how I wanted
plt.legend()
plt.show()