Hi all,
I was also a bit disappointed about the fact that 3d plotting support
was dropped. I'm happy to help out to get it going again, so here's a
patch to get surface plotting working; I'm busy with the contour plots
as well.
(We might want to do some code refactoring as well when it's functional).
Regards,
Reinier
On Wed, Mar 4, 2009 at 5:01 AM, Rob Clewley <rob.clew...@gmail.com> wrote:
> On Tue, Mar 3, 2009 at 11:39 AM, John Hunter <jdh2...@gmail.com> wrote:
>
>> Well, it is painfully slow, since it does everything in software, and there
>> are some corner cases where the zorder clipping is broken in the presence of
>> alpha transparency, and it doesn't do lighting, shadows, etc.... But it
>> does do enough for basic stuff, so we would be happy if you could resurrect
>> it cleanly enough for a toolkit.
>>
>
> I'd just like to add that having a *bare minimum* 3D capability in mpl
> is extremely useful to me -- i.e. being to visualize 3D data as a
> point cloud or a wireframe mesh. While teaching with python and doing
> numerical experiments in my research it's invaluable to be able to
> throw together a wholly non-publication quality 3D plot to get a quick
> idea of what's going on. I would imagine that others who use mpl
> professionally (and not necessarily only for public consumption) would
> agree on the value of maintaining this bare minimum even if there is
> no short- or medium-term expectation that it will develop into
> anything more sophisticated.
>
> Cheers,
> Rob
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
--
Reinier Heeres
Waalstraat 17
2515 XK Den Haag
The Netherlands
Tel: +31 6 10852639
From e53f81ac43193429fbe9670bc944cd095e0b7958 Mon Sep 17 00:00:00 2001
From: Reinier Heeres <rein...@heeres.eu>
Date: Wed, 4 Mar 2009 08:52:52 +0100
Subject: [PATCH] Fix surface plot
---
art3d.py | 16 ++++++++--------
axes3d.py | 9 ++++-----
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/art3d.py b/art3d.py
index 4e4912a..45ea1b3 100644
--- a/art3d.py
+++ b/art3d.py
@@ -138,8 +138,9 @@ class Line2DCollectionW(Wrap2D):
def draw3d(self, renderer):
#
+ segments_2d = [p.vertices for p in self.get_paths()]
segments_3d = [[juggle_axes(x,y,self.z,self.dir) for (x,y) in points]
- for points in self._segments]
+ for points in segments_2d]
xyslist = [
proj3d.proj_trans_points(points, renderer.M) for points in
segments_3d]
@@ -240,14 +241,13 @@ class oLine3DCollection(LineCollection):
class Poly3DCollection(Wrap2D):
def __init__(self, segments, *args, **kwargs):
- #inst = PolyCollection(segments, *args, **kwargs)
inst = PolyCollection([], *args, **kwargs)
-
+
Wrap2D.__init__(self, inst)
self._zsort = 1
+ self._segments3d = segments
self.get_vector()
self.remember('_facecolors')
- self.remember('_verts')
def get_vector(self):
"""optimise points for projection"""
@@ -255,7 +255,7 @@ class Poly3DCollection(Wrap2D):
ei = 0
segis = []
points = []
- for p in self._verts:
+ for p in self._segments3d:
points.extend(p)
ei = si+len(p)
segis.append((si,ei))
@@ -269,7 +269,7 @@ class Poly3DCollection(Wrap2D):
#
txs,tys,tzs,tis = proj3d.proj_transform_vec_clip(self.vec,renderer.M)
xyslist = [(txs[si:ei],tys[si:ei],tzs[si:ei],tis[si:ei]) for si,ei in self.segis]
- colors = get_colors(self._facecolors, len(self._verts))
+ colors = get_colors(self._facecolors, len(self._segments3d))
#
# if required sort by depth (furthest drawn first)
if self._zsort:
@@ -281,7 +281,7 @@ class Poly3DCollection(Wrap2D):
raise ValueError, "whoops"
segments_2d = [s for z,i,s,c in z_segments_2d if i]
colors = [c for z,i,s,c in z_segments_2d if i]
- self._verts = segments_2d
+ self.set_verts(segments_2d)
self._facecolors = colors
self.draw2d(renderer)
@@ -419,7 +419,7 @@ def draw_linec(self, renderer):
self._segments = orig_segments
def draw_polyc(self, renderer):
- orig_segments = self._verts
+ orig_segments = [p.vertices for p in self.get_paths()]
# process the list of lists of 2D points held in _verts to generate
# a list of lists of 3D points
segments_3d = [[(x,y,z) for (x,y),z in zip(points,self.zs)]
diff --git a/axes3d.py b/axes3d.py
index 1f8f851..16d1088 100644
--- a/axes3d.py
+++ b/axes3d.py
@@ -532,7 +532,6 @@ class Axes3DI(Axes):
plot3d=plot3D
- """
def plot_surface(self, X, Y, Z, *args, **kwargs):
had_data = self.has_data()
@@ -579,7 +578,7 @@ class Axes3DI(Axes):
#
self.auto_scale_xyz(X,Y,Z, had_data)
return polyc
- """
+
def plot_wireframe(self, X, Y, Z, *args, **kwargs):
rstride = kwargs.pop("rstride", 1)
cstride = kwargs.pop("cstride", 1)
@@ -779,7 +778,7 @@ def test_wire():
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
-"""
+
def test_surface():
from matplotlib import pyplot as plt
f = plt.figure()
@@ -803,7 +802,7 @@ def test_contour():
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
-"""
+
def test_plot():
from matplotlib import pyplot as plt
f = plt.figure()
@@ -879,9 +878,9 @@ if __name__ == "__main__":
# These tests work (sorta).
#test_scatter()
#test_wire()
+ #test_surface()
# These don't.
- #test_surface()
#test_contour()
#test_plot()
#test_polys()
--
1.5.6.3
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel