import matplotlib.pyplot as plt
from pylab import *
import numpy as np
x = np.linspace(0, 2*np.pi, 400)
y = np.sin(x**2)
subplots_adjust(hspace=0.000)
number_of_subplots=3
for i,v in enumerate(xrange(number_of_subplots)):
v = v+1
ax1 = subplot(number_of_subplots,1,v)
ax1.plot(x,y)
plt.show()
This code works but you will need to correct the axes. I used to subplot
to plot 3 graphs all in the same column. All you need to do is assign an integer to number_of_plots
variable. If the X and Y values are different for each plot you will need to assign them for each plot.
subplot
works as follows, if for example I had a subplot values of 3,1,1
. This creates a 3x1 grid and places the plot in the 1st position. In the next interation if my subplot
values were 3,1,2
it again creates a 3x1 grid but places the plot in the 2nd position and so forth.