[Matplotlib-users] 3d plotting question

2007-04-11 Thread belinda thom
Hi,

I'm having problems plotting two different kind of graphs on the same  
3D figure. Was hoping for some pointers.

Here's some basic test code, to demonstrate what I'd like to be able  
to do.

import copy
import pylab as P
import matplotlib.axes3d as P3
def test() :
 [X,Y] = P.meshgrid(P.linspace(-3,3,7),P.linspace(-3,3,7))
 Z = copy.deepcopy(X)
 Z1 = copy.deepcopy(X)
 for i in xrange(len(X)) :
 for j in xrange(len(X[0])) :
 Z[i][j] = X[i][j]*Y[i][j]
 Z1[i][j] = X[i][j]*Y[i][j] - 5
 P.close('all')
 fig = P.figure()
 ax = P3.Axes3D(fig)
 ax.scatter3D(P.ravel(X),P.ravel(Y),P.ravel(Z))
 ax.set_xlabel('x')
 ax.set_ylabel('y')
 ax.set_zlabel('z=x*y')
 P.show()
 ax.plot3D(P.ravel(X),P.ravel(Y),P.ravel(Z1))
 P.show()

Which produces an autoscale_view kwarg error appended below. I've  
tried calling plot3D with scalex=False and scaleY=False but that  
doesn't fix the problem. I've also tried creating a new axis (e.g.  
ax1) and doing ax1.Plot3D to no avail. It seems to be an error w/in  
matplotlib, but perhaps I'm misusing something. I haven't been able  
to find much documentation for this at http://www.scipy.org/Cookbook/ 
Matplotlib/mplot3D so have resorted to playing around.

If anyone also knows how to pass color-marker info into scatter3D, I  
have been able to create two of those on the same figure, so being  
able to change the colors of each and just using scatter3D would be a  
reasonable hack for my situation.

Advice always appreciated,

--b

In [25]: T.test()
 
---
exceptions.TypeError Traceback (most  
recent call last)

/Users/bthom/belinda/mills/aicourse/material/week12/lec/examples/ 
ipython console

/Users/bthom/belinda/mills/aicourse/material/week12/lec/examples/ 
threeD.py in test()
  18 ax.set_zlabel('z=x*y')
  19 P.show()
--- 20 ax.plot3D(P.ravel(X),P.ravel(Y),P.ravel(Z1))
  21 P.show()
  22

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/axes3d.py in plot3D(self, xs, ys, zs, *args,  
**kwargs)
 488 def plot3D(self, xs, ys, zs, *args, **kwargs):
 489 had_data = self.has_data()
-- 490 lines = Axes.plot(self, xs,ys, *args, **kwargs)
 491 if len(lines)==1:
 492 line = lines[0]

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/axes.py in plot(self, *args, **kwargs)
2129 lines = [line for line in lines] # consume the  
generator
2130
- 2131 self.autoscale_view(scalex=scalex, scaley=scaley)
2132 return lines
2133

TypeError: autoscale_view() got an unexpected keyword argument 'scalex'
  /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/ 
site-packages/matplotlib/axes.py(2131)plot()
2130
- 2131 self.autoscale_view(scalex=scalex, scaley=scaley)
2132 return lines


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 3d plotting question

2007-04-11 Thread belinda thom
I also seem to have some other 3D plotting problems. Again, following  
some of the demo/test advice in the cookbook, I tried things like

   import pylab as p
   import matplotlib.axes3d as P3
   P3.test_surface()

and get errors (seems Axes3D needs a figure, no?).

I'm using matplotlib version 0.87.7.

Any ideas?

Thx,

--b


In [49]: P3.test_surface()
 
---
exceptions.TypeError Traceback (most  
recent call last)

/Users/bthom/belinda/mills/aicourse/material/week12/lec/examples/ 
ipython console

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/axes3d.py in test_surface()
 739
 740 def test_surface():
-- 741 ax = Axes3D()
 742
 743 X,Y,Z = get_test_data(0.05)

TypeError: __init__() takes at least 2 arguments (1 given)
  /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/ 
site-packages/matplotlib/axes3d.py(741)test_surface()
 740 def test_surface():
-- 741 ax = Axes3D()
 742

ipdb

In [50]: P3.test_surface?
Type:   function
Base Class: type 'function'
String Form:function test_surface at 0x304a070
Namespace:  Interactive
File:   /Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/matplotlib/axes3d.py
Definition: P3.test_surface()
Docstring:
 no docstring


In [51]: P3.test_surface()
 
---
exceptions.TypeError Traceback (most  
recent call last)

/Users/bthom/belinda/mills/aicourse/material/week12/lec/examples/ 
ipython console

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/axes3d.py in test_surface()
 739
 740 def test_surface():
-- 741 ax = Axes3D()
 742
 743 X,Y,Z = get_test_data(0.05)

TypeError: __init__() takes at least 2 arguments (1 given)
  /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/ 
site-packages/matplotlib/axes3d.py(741)test_surface()
 740 def test_surface():
-- 741 ax = Axes3D()
 742

ipdb

In [52]: P3.test_contour()
 
---
exceptions.TypeError Traceback (most  
recent call last)

/Users/bthom/belinda/mills/aicourse/material/week12/lec/examples/ 
ipython console

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/axes3d.py in test_contour()
 750
 751 def test_contour():
-- 752 ax = Axes3D()
 753
 754 X,Y,Z = get_test_data(0.05)

TypeError: __init__() takes at least 2 arguments (1 given)
  /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/ 
site-packages/matplotlib/axes3d.py(752)test_contour()
 751 def test_contour():
-- 752 ax = Axes3D()
 753

ipdb 

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 3d plotting question

2007-04-11 Thread belinda thom
Thanks for the input.

Its easy for me to patch my own machine, but for students in my class  
who are using lab machines, its more difficult. Hopefully I can get  
someone to upgrade the machines in the lab I'm using. (Its difficult  
to get facilities people to agree to update coursework installs mid- 
semester).

Morale of my story: don't expect 3d plotting to necessarily work / be  
easy if you don't carefully test it first :-(.

I too would be interested in robustifying / making more accessible  
the 3d stuff, but will have to wait until after the class I'm  
teaching ends.

--b


On Apr 11, 2007, at 6:57 PM, Tim Leslie wrote:

 Even in the lastest svn version these test methods are all broken to a
 greater or lesser degree (as I found out a couple of days ago). If I
 find time over the weekend I'll try to fix them up. In the mean time,
 if you change them to look something like

 fig = pylab.figure()
 ax = Axes3d(fig)
 ... etc

 it should get you one step closer to having them working. I'll post
 back here if/when I manage to get them cleaned up.

 Cheers,

 Tim



-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 3d plotting question

2007-04-11 Thread belinda thom
 Hi Belinda,

 I've been playing with 3D plots and scatter plots in the past few days
 and I've been able to get them working. You should be able to pass in
 a c=color parameter as you would for a normal 2d scatter plot. I've
 been doing this and it's working for me.

Interesting.

I'm on Mac OS X 4.8.9, running Python 2.4.4, using Matplotlib 0.87.7  
w/TkAgg (I might be using Wx, but would have to get a problem w/my  
machine's and all the students' lab machines wx libraries updated).

When I try using the c='r' parameter, I run into problems. I also  
tried c='red'. One big problem for me is that which kwargs can be  
used where and what values they can take on is not well documented.

For instance, in plot3d (as opposed to plot3D) you can pass the  
typical Matplotlib 'r.-' string and it just works. But in  
plot_wireframe, for example, it appears you must use different kwargs  
(for instance, linestyle='solid' and color='some RGB value'). I am  
not sure about these notions, b/c I've had to deduce them from the  
code and various google-based snippets.

That's why I'm asking for more guidance about the various kwarg usages.

Is there any good place to find more cohesive info online? The most  
useful place I could find seemed to be in matplotlib's  
collections.py, an __init__ function's documentation (that's where I  
deduced, for instance, the linestyle and RGB color info). If there  
isn't such a place, someone should probably modify the matplotlib 3d  
cookbook. I'd be willing to do that but I'd first need to have a  
better understanding about the various functions' kwargs :-).

I'll append a case I used to generate an error, as well as the error  
reporting below. I'm also not quite sure how to use the errors that  
are reported to help me track down where the problems might be, so if  
anyone has some advice on that, it might help me better help myself  
in the future.

As always, thx,

--b


Example Code:
-
import copy
import pylab as P
import matplotlib.axes3d as P3
def test() :
 [X,Y] = P.meshgrid(P.linspace(-3,3,7),P.linspace(-3,3,7))
 Z = copy.deepcopy(X)
 Z1 = copy.deepcopy(X)
 for i in xrange(len(X)) :
 for j in xrange(len(X[0])) :
 Z[i][j] = X[i][j]*Y[i][j]
 Z1[i][j] = X[i][j]*Y[i][j] - 5
 P.close('all')
 fig = P.figure()
 ax = P3.Axes3D(fig)
 ax.Plot3D(ravel(X),ravel(Y),ravel(Z),c='r')

In [213]: T.test()
 
---
exceptions.AttributeErrorTraceback (most  
recent call last)

/Users/bthom/belinda/mills/aicourse/material/week12/lec/examples/ 
ipython console

/Users/bthom/belinda/mills/aicourse/material/week12/lec/examples/ 
threeDa.py in test()
  11 Z1[i][j] = X[i][j]*Y[i][j] - 5
  12 P.close('all')
  13 fig = P.figure()
  14 ax = P3.Axes3D(fig)
--- 15 ax.Plot3D(ravel(X),ravel(Y),ravel(Z),c='red')

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/matplotlib/axes3d.py in __getattr__(self, k)
 660
 661 def __getattr__(self, k):
-- 662 return getattr(self.wrapped,k)
 663
 664 def __setattr__(self, k,v):

AttributeError: Axes3DI instance has no attribute 'Plot3D'
  /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/ 
site-packages/matplotlib/axes3d.py(662)__getattr__()
 661 def __getattr__(self, k):
-- 662 return getattr(self.wrapped,k)
 663

ipdb 

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Matplotlib-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users