How To Plot The Piecewise Continuous Points In Matplotlib
My dataset is as follows: G R Y 1 1 0 1 2 1 1 3 2 1 4 4 1 5 2 2 1 1 2 2 2 2 3 3 2 4 2 3 1 0 3 2 1 3 3 2 3 4 2 3 5 3 I want to know how to write the correct matplotlib code to plot
Solution 1:
You could just split up your data according to the three sections you have, graph each group separately, and then attach the graphs together:
fig, axes = plt.subplots(1, 3, sharey=True)
Y = [0, 1, 2, 4, 2, 1, 2, 3, 2, 0, 1, 2, 2, 3]
Y0 = Y[0:6]
Y1 = Y[5:10]
Y2 = Y[9:15]
axes[0].plot(Y0)
axes[1].plot(Y1)
axes[2].plot(Y2)
plt.ylim([0, 5])
subplots_adjust(wspace=0)
That will get you pretty close to what you need (though I admit some of the the x-axes could use a little extra formatting):
If I were you I would enter that line by line, hitting plt.draw()
after every line of matplotlib code to see what exactly is going on.
Post a Comment for "How To Plot The Piecewise Continuous Points In Matplotlib"