|
From: Symion <kn...@ip...> - 2010-10-07 18:15:28
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
On 28/09/2010 2:17 AM, Bruce Sherwood wrote:
<blockquote
cite="mid:AAN...@ma..."
type="cite">
<pre wrap="">Some VPython users have from time to time expressed a strong desire to
be able to import Visual selectively, without including math and
numpy, and recently I showed how to do this.
Over a week ago I asked for feedback on the best way to document this,
and I really do need your feedback, especially because one of the
schemes I proposed would require not just documentation but also new
files vobjects.py and vectors.py to be included in the Visual package.
If selective import matters to you, please post a note about your
preferences on how you would like to see this documented, and whether
you want files vobjects.py and vectors.py to be part of the package.
Thanks.
Bruce Sherwood
</pre>
</blockquote>
Hi there,<br>
This is probably a naive question, but why not implement visual
the same way as the other modules?<br>
<br>
EXAMPLE:<br>
<br>
import visual as vp<br>
import scipy as sp<br>
import matplotlib as mpl<br>
import matplotlib.pyplot as plt<br>
from visual.graph import (gdisplay, gcurve, gvbars, gdots,
ghistogram)<br>
<br>
oscillation = gdisplay(xtitle='Time', ytitle='Response')<br>
funct1 = gcurve(color=vp.color.cyan)<br>
funct2 = gvbars(delta=0.5, color=vp.color.red)<br>
funct3 = gdots(color=vp.color.yellow)<br>
<br>
for t in vp.arange(-30, 74, 1):<br>
funct1.plot(pos=(t, 5.0+5.0*vp.cos(-0.2*t)*vp.exp(0.015*t)))<br>
funct2.plot(pos=(t, 2.0+5.0*vp.cos(-0.1*t)*vp.exp(0.015*t)))<br>
funct3.plot(pos=(t, 0.0+5.0*vp.cos(-0.03*t)*vp.exp(0.015*t)))<br>
<br>
histo = gdisplay(title='Histogram', x=0, y=400,
width=800,height=400)<br>
datalist1 = [5, 37, 12, 21, 25, 28, 8, 63, 52, 75, 7]<br>
data = ghistogram(bins=vp.arange(-20, 80, 10), color=vp.color.red)<br>
data.plot(data=datalist1) <br>
datalist2 = [7, 23, 25, 72, -15]<br>
data.plot(data=datalist2, accumulate=1)<br>
<br>
print dir()<br>
<br>
*****<br>
<br>
One might say I have simply swept any problem under a carpet called
'vp', but if the problem is with<br>
the global namespace issue and/or the need to conform to a Pythonic
style then:<br>
This instantiation method conforms to standard python fair<br>
The number of items in the namespace is now reduced to a
handful.<br>
And the slightly modified 'examples' program seems to works fine
- on my system?<br>
<br>
</body>
</html>
|