mardi 4 août 2015

Matplotlib plotting- two data sets with different no. of data points

I am trying to plot two data sets into the same graph using matplotlib. No. of data points for the first pair of (x1,y1) is 150. No. of data points for the second pair (x2,y2) is 100. Please note that the range for x1 and x2 is from 0.0 to 1.0. Only the no. of data points are different. When I try to plot these into the same graph for comparison, the error message appears that "x and y must have same first dimension". Code snippet below for your reference:

def main():
 x1,y1 = np.loadtxt('txt1.txt',unpack=True)
 x2,y2 = np.loadtxt('txt2.txt',unpack=True)
 plt.figure()
 plt.plot(x1,y1)
 plt.plot(x2,y2)
main()



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire