On Sun, Aug 1, 2010 at 9:55 AM, Tom Arens <tak...@gmx.de> wrote:

> Hello everyone,
>
> does anybody know why the contour3D function has a fixed set of levels?
>
> contour3D(X, Y, Z, levels=10, **kwargs)
>
> I want to plot only one line for one level. With "contourf" it works:
>
>
>
> from mpl_toolkits.mplot3d import axes3d
> import matplotlib.pyplot as plt
>
> fig = plt.figure()
> ax = axes3d.Axes3D(fig)
> X, Y, Z = axes3d.get_test_data(0.05)
> cset = ax.contourf(X, Y, Z, 0)  # doesn't work with contour
> ax.clabel(cset, fontsize=9, inline=1)
>
> plt.show()
>
>
>
> Many greetings,
> Tom
>
>
Hmm, interesting.  Looking at the contour3d call signature, it appears that
'levels' was put into the call signature to basically remove that keyword
argument from the kwargs that get passed down to the 2-d version of
contour.  It is never used in the body of contour3d().

I would guess that this is might be a remnant of some original code that
actually used the levels parameter.  Simply removing levels=0 from the call
signature seems to fix it (and passing [0] to levels as well since it
expects a sequence).

As a matter of consistency, I think the call signature should be changed to
better match the call signature for contourf3d() and for the 2-d version of
contour().

Ben Root
Index: lib/mpl_toolkits/mplot3d/axes3d.py
===================================================================
--- lib/mpl_toolkits/mplot3d/axes3d.py	(revision 8609)
+++ lib/mpl_toolkits/mplot3d/axes3d.py	(working copy)
@@ -896,7 +896,7 @@
         for col in colls:
             self.collections.remove(col)
 
-    def contour(self, X, Y, Z, levels=10, **kwargs):
+    def contour(self, X, Y, Z, *args, **kwargs):
         '''
         Create a 3D contour plot.
 
@@ -912,7 +912,7 @@
                     lines on this position in plane normal to zdir
         ==========  ================================================
 
-        Other keyword arguments are passed on to
+        The positional and other keyword arguments are passed on to
         :func:`~matplotlib.axes.Axes.contour`
 
         Returns a :class:`~matplotlib.axes.Axes.contour`
@@ -926,7 +926,7 @@
         had_data = self.has_data()
 
         jX, jY, jZ = art3d.rotate_axes(X, Y, Z, zdir)
-        cset = Axes.contour(self, jX, jY, jZ, **kwargs)
+        cset = Axes.contour(self, jX, jY, jZ, *args, **kwargs)
 
         zdir = '-' + zdir
         if extend3d:
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to