hi all, i installed matplotlib, numpy and scipy. i tried to run attached script to learn how it plot a grph but got error as below: Traceback (most recent call last): File "C:\Python25\myscript\plot\plot1.py", line 3, in <module> from scipy import * File "C:\Python25\Lib\site-packages\scipy\linalg\__init__.py", line 31, in <module> from numpy.testing import NumpyTest ImportError: cannot import name NumpyTest pls advise. thanks
From: waynejwer...@gmail.com Date: Tue, 18 Jan 2011 06:14:07 -0600 Subject: Re: [Tutor] How to plot graph? To: tc...@hotmail.com CC: tutor@python.org On Tue, Jan 18, 2011 at 4:30 AM, tee chwee liong <tc...@hotmail.com> wrote: hi all, i'm new to python and this is advanced for me. is there a way to plot data with python? i want to plot EyVt, EyHt on the Y-axis and Lane on the X-axis as attached or below. currently i'm using Python2.5 and Win XP. thanks a lot. Take a look at the matplotlib library: http://matplotlib.sourceforge.net/ Especially the gallery page - there are several examples of what you can do. It may not be the easiest thing to start into as a beginner, but it's definitely available. If you're interested in doing a lot of scientific stuff, I'd also recommend using Python(X, Y): http://www.pythonxy.com/ as it bundles most of the tools you'll need (such as matplotlib) into one easy installer. Give it a try and if you get stuck, send us another email with what you've done, what you expect it to do, and what it actually does instead (including the full text of any and all tracebacks). HTH, Wayne
import numpy as np from numpy import cos from scipy import * from pylab import plot, show, ylim, yticks from matplotlib import * from pprint import pprint n1 = 1.0 n2 = 1.5 #alpha, beta, intensity data = np.array([ [10, 22, 4.3], [20, 42, 4.2], [30, 62, 3.6], [40, 83, 1.3], [45, 102, 2.8], [50, 123, 3.0], [60, 143, 3.2], [70, 163, 3.8], ]) # Populate arrays x = np.array([row[0] for row in data]) y1 = np.array([row[1] for row in data]) rhotang1 = n1*cos(data[:,0]) - n2*cos(data[:,1]) rhotang2 = n1*cos(data[:,0]) + n2*cos(data[:,1]) y3 = rhotang1 / rhotang2 plot(x, y1, 'r--', x, y3, 'g--') show()
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor