[SciPy-User] Dimensions of x and y are incompatible
Pierre GM
pgmdevlist at gmail.com
Mon Aug 3 17:42:37 EDT 2009
On Aug 3, 2009, at 5:26 PM, Omer Khalid wrote:
> Hi,
Omer,
You do realize this is the Scipy mailing list, right ? You should ask
matplotlib related questions to the matplotlib mailing list:
matplotlib-users at lists.sourceforge.net
Anyhow:
> "Dimensions of x and y are incompatible"
means what it means: you're trying to plot y (size 11) with x of size
(110). That won't do: your x and y must have the same size (else, what
happens to the extras x or y ?)
Moreover, you may want to use np.linspace instead of np.arange for that:
np.linspace(0,1,11) gives you 11 points regularly spaced between 0 and
1.
> I am trying to plot two curves on a same graph. The two input
> datasets are xdata, ydata and they range between (0.01, 1] for
> xdata and (0.1, 1] for ydata.
>
> I am constantly getting this error when plotting "Dimensions of x
> and y are incompatible"
>
> plt.figure()
> xdata= array(xd)
> ydata = array(xd)
>
> N=len(xdata)
> print "N: %d" % (N)
> x=arange(0.0, 1.0+0.01, 0.01)
> M=len(ydata)
> print "M: %d" % (M)
> y=arange(0.0, 1.0+0.1, 0.1)
> plt.plot(x,xdata,'r')
> plt.plot(y,ydata,'b')
> plot.legend((xl,yl))
> plt.grid(True)
> plt.title(title)
> plt.xlabel('Value Ratio')
> plt.ylabel('Simulation Time Unit')
> pdf_name = '%s-%s.pdf' % (str(filename),strftime("%m
> %d-%M-%S"))
> pwd = os.getcwd()
> path = os.path.join(pwd, exp, pdf_name)
> plt.savefig(path)
>
> I have also tried:
> x=arange(1,N)
> y=arange(1,M)
>
> But it didn't work. Any help would be much appreciated.
>
> Thanks,
> Omer
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
More information about the SciPy-User
mailing list