On Mon, Apr 11, 2011 at 4:16 AM, Konrad Bartkowski <
k.bartkow...@fz-juelich.de> wrote:
> Ok, forwarding it to the matplotlib-devel list.
>
>
> Best wishes,
>
> Konrad (on behalf of our workgroup)
>
>
> -------- Original Message -------- Subject: Source of inaccuracies in the
> matplotlib library Date: Fri, 8 Apr 2011 18:12:47 +0200 From: Bartkowski,
> Konrad <k.bartkow...@fz-juelich.de> <k.bartkow...@fz-juelich.de> To:
> d...@cornell.edu <d...@cornell.edu> <d...@cornell.edu>, md...@stsci.edu
> <md...@stsci.edu> <md...@stsci.edu>, efir...@hawaii.edu
> <efir...@hawaii.edu> <efir...@hawaii.edu>, jdhun...@ace.bsd.uchicago.edu
> <jdhun...@ace.bsd.uchicago.edu> <jdhun...@ace.bsd.uchicago.edu>,
> jdh2...@gmail.com <jdh2...@gmail.com> <jdh2...@gmail.com> CC: Bartkowski,
> Konrad <k.bartkow...@fz-juelich.de> <k.bartkow...@fz-juelich.de>,
> el...@interia.pl <el...@interia.pl> <el...@interia.pl>, Matthias Bolten
> <bol...@math.uni-wuppertal.de> <bol...@math.uni-wuppertal.de>,
> Grotendorst, Johannes
> <j.grotendo...@fz-juelich.de><j.grotendo...@fz-juelich.de>,
> Steffen, Bernhard <b.stef...@fz-juelich.de> <b.stef...@fz-juelich.de>
>
> Dear Matplotlib developers,
>
> I am writing about the matplotlib library with the mpl_toolkits. First
> of all let me emphasize how great software it is. Recently, in one of
> our projects we were rendering big surfaces and encountered the
> following problem:
> http://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg06869.html
>
> It's not a bug (which all in all is a natural and unavoidable ingredient
> of the software, and especially in such a big and complex system like
> matplotlib would be fully natural), since the software does exactly the
> projection mathematics that it is expected to do, but a source of the
> inaccuracies, which is especially visible in the critical examples. For
> the profit of the Python community we are sending You a proposition of a
> modification of the surface plotting rendering system, in case You find
> it interesting enough to include in the consecutive version of the
> library. In the source code from the attachment we redesigned a little
> bit the computation process – since the computations are especially
> sensible to numerical errors, that are for example amplified while
> norming or processing the quaterions in the various stages (for example
> division over coordinate in the perspective projection). Therefore the
> computational focus can be shifted from the Polygon collection to the
> polygons itself. In the example from the above forum or the slightly
> modified one, one can observe a big difference in the numerical
> precision while the speed of the computations does not decrease (at
> least visibly). While instead of the surfaces from the forum, the
> following surfaces are rendered:
>
> u = np.linspace(0, 2 * np.pi, 100)
> v = np.linspace(0, np.pi, 100)
>
> x = 10 * np.outer(np.cos(u), np.sin(v))
> y = 10 * np.outer(np.sin(u), np.sin(v))
> z = 10 * np.outer(np.ones(np.size(u)), np.cos(v))
>
> ax.plot_surface(x, y, z, rstride=8, cstride=8, color='y', alpha=0.5)
> shiftX=28
> shiftY=28
> X,Y=np.meshgrid(range(-20+shiftX,20+shiftX),range(-20+shiftY,20+shiftY))
> Z=np.ones((X.shape[0], Y.shape[1]))
> ax.plot_surface(X, Y, Z, color='r', rstride=10, cstride=10, alpha=1.0)
>
> the issue is visible for example at the azimuth=40 , elevation=70 – with
> those parameters the mentioned case is visible on the red surface, while
> with elevation=68 not. Moreover, now also the stride is big (in the new
> approach the influence of increasing stride on the numerical precision
> grows).
> So again let me use this opportunity to thank You for empowering the
> Python community worldwide in a great, powerful scientific visualization
> tool.
>
> Best wishes,
> Konrad Bartkowski
>
>
>
Konrad,
Ok, I have examined the attached file, and I see what you have done. First,
the shading issue has long since been resolved and is in the development
branch (but probably won't be backported to v1.0.x because the changes were
extensive).
Second, the zorder sorting issue is a PITA to say the least. Your approach,
however, only pushes the problem down to smaller parts, and still doesn't
address the same problems with PatchCollection objects. That being said, I
would still be inclined to have the problem solved for surfaces and leave
patches to be buggy, except that this approach completely breaks the API.
plot_surface returns a Poly3DCollection object, not a list of
Poly3DCollection objects.
The Collections object is a double-edge sword. It allows for easy
manipulation of many artist objects, but ultimately the Collection object
must report a single z-order value to represent the z-order for plotting all
of the artist elements.
There might be a possible work-around, though. Maybe (and I am just
speculating here) if we can get the core part of matplotlib to specially
treat 3d collection objects in such a way that allows the collection to
return provide elements and z-order pairs. It is either that, or we finally
try to get OpenGL working again in matplotlib and allow ourselves to specify
coordinates in 3-D.
Ben Root
------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel