mplot3d: disable z-sorting?

Sebastian, looking at those images, I have to wonder if there is a bug in how bar3d is reporting the z-order. These rendering mistakes do not seem to follow the same patterns that I have seen with manually setting polygon objects. I will take a deeper look into it.

Ben Root

···

On Thu, Jan 6, 2011 at 12:57 AM, Sebastian Voigt <svoigt@…380…> wrote:

Am 06.01.2011 02:14, schrieb Benjamin Root:

    On Wed, Jan 5, 2011 at 6:15 PM, Sebastian > > Voigt <svoigt@...380...> > >         wrote:
      I've been running into the well known rendering problems with

mplot3d’s

      bar3d function. After two days of trying to get acceptable

results

      without success: Is it possible to simply disable z-sorting

(whoops)?

      I want to generate static plots from experimental data, all

using the

      same perspective, so I know the order of the bars to be

plotted. It’s a

      no-brainer to provide the data vectors in this appropriate

order, which

      I tried too - didn't work. Even if I provide explicit zorders

for all

      Poly3dCollections in axes.collections (single-plotting each

bar),

      everything gets messed up after showing the plot window.



      So is there any way to create the bars just in the order of

the data

      vectors passed to bar3d (or keep the order/zorder in

axes.collections)?

          - Sebastian Voigt -
      There are well-known rendering issues with mplot3d in general,

but I am not aware of one with respect to bar3d. Can you
please include a image of the rendering defect that you are
seeing?

      And no, there is no way to disable z-sorting that I am aware

of because it is inherent in matplotlib’s system. mplot3d
merely utilizes the drawing facilities that matplotlib
provides.

      Ben Root

It’s exactly the same problem as described in

http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg15243.html

see the second sample pic in this post. If I cannot disable

z-sorting, how can I control it? Artist have a set_zorder() method,
but providing correct z-levels for all my artists seems to be
ignored.

Sebastian

Ok, I have figure out what is wrong here. First of all, thank you for pointing out this whole issue, because my investigations lead me to realize some other bugs that are currently in the development trunk (I have to see if they are in the 1.0.1 branch as well).

As for the issue with bar3d. The graphs look much better when you plot each row of bars (or even better if you plot each bar separately). This is because bar3d creates a Poly3DCollection and will do its best to sort the collection elements internally with respect to each other. However, when you have two objects from two separate Poly3DCollections (or any two 3D collection objects, for that matter) that occupy the same region in space, then you will have problems.

Each Poly3DCollection object reports a scalar zsort value that is supposed to represent the zsort value of all its elements. This is fine if the collections are spatially distinct, or if the scalar zsort value is equal to the zsort value of all the elements.

Try out the attached modified script. You can see that by looping through the bars, you get a much better result (although it is still not perfect due to the already established issues). I am not exactly sure how to resolve this, but at least it is documented here for posterity.

Ben Root

bar3d_badness.py (1.08 KB)

···

On Thu, Jan 6, 2011 at 11:47 AM, Benjamin Root <ben.root@…3146…4…> wrote:

On Thu, Jan 6, 2011 at 12:57 AM, Sebastian Voigt <svoigt@…380…> wrote:

Am 06.01.2011 02:14, schrieb Benjamin Root:

    On Wed, Jan 5, 2011 at 6:15 PM, Sebastian > > > Voigt <svoigt@...380...> > > >         wrote:
      I've been running into the well known rendering problems with

mplot3d’s

      bar3d function. After two days of trying to get acceptable

results

      without success: Is it possible to simply disable z-sorting

(whoops)?

      I want to generate static plots from experimental data, all

using the

      same perspective, so I know the order of the bars to be

plotted. It’s a

      no-brainer to provide the data vectors in this appropriate

order, which

      I tried too - didn't work. Even if I provide explicit zorders

for all

      Poly3dCollections in axes.collections (single-plotting each

bar),

      everything gets messed up after showing the plot window.



      So is there any way to create the bars just in the order of

the data

      vectors passed to bar3d (or keep the order/zorder in

axes.collections)?

          - Sebastian Voigt -
      There are well-known rendering issues with mplot3d in general,

but I am not aware of one with respect to bar3d. Can you
please include a image of the rendering defect that you are
seeing?

      And no, there is no way to disable z-sorting that I am aware

of because it is inherent in matplotlib’s system. mplot3d
merely utilizes the drawing facilities that matplotlib
provides.

      Ben Root

It’s exactly the same problem as described in

http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg15243.html

see the second sample pic in this post. If I cannot disable

z-sorting, how can I control it? Artist have a set_zorder() method,
but providing correct z-levels for all my artists seems to be
ignored.

Sebastian

Sebastian, looking at those images, I have to wonder if there is a bug in how bar3d is reporting the z-order. These rendering mistakes do not seem to follow the same patterns that I have seen with manually setting polygon objects. I will take a deeper look into it.

Ben Root