I am trying to plot a scatter chart using numpy and matplotlib. It is very simple, I have 2 data files, each contains single column set of data. Both files have same number of data (I've checked this over and over again to make sure).
This is what I've done:
import numpy as np import pylab as pl xdata = np.loadtxt('data.txt') ydata = np.loadtxt('data1.txt') pl.plot(xdata, ydata, 'ro') pl.show()
and it gives me this error
File "C:/1aProjects/Python_Aryo/Plotting/test_plot.py", line 10, in <module> pl.plot(xdata, ydata, 'ro') File "C:\Python34\lib\site-packages\matplotlib\pyplot.py", line 2987, in plot ret = ax.plot(*args, **kwargs) File "C:\Python34\lib\site-packages\matplotlib\axes.py", line 4144, in plot for line in self._get_lines(*args, **kwargs): File "C:\Python34\lib\site-packages\matplotlib\axes.py", line 319, in _grab_next_args for seg in self._plot_args(remaining, kwargs): File "C:\Python34\lib\site-packages\matplotlib\axes.py", line 297, in _plot_args x, y = self._xy_from_xy(x, y) File "C:\Python34\lib\site-packages\matplotlib\axes.py", line 239, in _xy_from_xy raise ValueError("x and y must have same first dimension") ValueError: x and y must have same first dimension
it says the data does not have the same dimension.
Then I tried to plot only in certain range, and it works but until row no 72402 as shown below.
pl.plot(xdata[0:72402], ydata[0:72402], 'ro')
if I put anything more than 72402, it gives me the same error msg. Telling that the array does not have the same size. My data actually has up row 72413!, it is just 11 more rows! it is quite annoying isn't it?
Can anyone help?
xdata.shape
andydata.shape
?