matplot3d: add_collection3d: Turn off baseline?

I want to plot a series of (x,y) datasets similar to the
polygon plot tutorial example (add_collection3d),
but with a transparent facecolor and no baseline.

Setting alpha=0.0 in the tutorial example (below)
achieves the transparency, but the baseline remains.

Is there a way to remove the baseline?

Tks,

Steve.

from mpl_toolkits.mplot3d import Axes3D
from matplotlib.collections import PolyCollection
from matplotlib.colors import colorConverter
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.gca(projection='3d')

cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.0)

xs = np.arange(0, 10, 0.4)
verts = []
zs = [0.0, 1.0, 2.0, 3.0]
for z in zs:
     ys = np.random.rand(len(xs))
     ys[0], ys[-1] = 0, 0
     verts.append(list(zip(xs, ys)))

poly = PolyCollection(verts, facecolors = [cc('r'), cc('g'), cc('b'),
                                            cc('y')])
#poly.set_alpha(0.7)
ax.add_collection3d(poly, zs=zs, zdir='y')

ax.set_xlabel('X')
ax.set_xlim3d(0, 10)
ax.set_ylabel('Y')
ax.set_ylim3d(-1, 4)
ax.set_zlabel('Z')
ax.set_zlim3d(0, 1)

You should be able to set “edgecolors=‘none’” or as the same color as the facecolors in the constructor for PolyCollection to make it disappear. Unfortunately, that would apply to the entire polygon, and not just the part at the base.

Ben Root

···

On Tue, Nov 20, 2012 at 12:55 AM, Stephen Gibson <Stephen.Gibson@…634…> wrote:

I want to plot a series of (x,y) datasets similar to the

polygon plot tutorial example (add_collection3d),

but with a transparent facecolor and no baseline.

Setting alpha=0.0 in the tutorial example (below)

achieves the transparency, but the baseline remains.

Is there a way to remove the baseline?

Tks,

Steve.

from mpl_toolkits.mplot3d import Axes3D

from matplotlib.collections import PolyCollection

from matplotlib.colors import colorConverter

import matplotlib.pyplot as plt

import numpy as np

fig = plt.figure()

ax = fig.gca(projection=‘3d’)

cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.0)

xs = np.arange(0, 10, 0.4)

verts = []

zs = [0.0, 1.0, 2.0, 3.0]

for z in zs:

 ys = np.random.rand(len(xs))

 ys[0], ys[-1] = 0, 0

 verts.append(list(zip(xs, ys)))

poly = PolyCollection(verts, facecolors = [cc(‘r’), cc(‘g’), cc(‘b’),

                                        cc('y')])

#poly.set_alpha(0.7)

ax.add_collection3d(poly, zs=zs, zdir=‘y’)

ax.set_xlabel(‘X’)

ax.set_xlim3d(0, 10)

ax.set_ylabel(‘Y’)

ax.set_ylim3d(-1, 4)

ax.set_zlabel(‘Z’)

ax.set_zlim3d(0, 1)

Unfortunately, as you state, "edgecolors='none'" also wipes the
(x,y) data line.

I tried adding an additional "erase" zero line, with "edgecolors='none'"
for each slice, but it seems the return path extends from
(x[0],y[0]) to (x[-1],y[-1]) via some intermediate point.

An additional blank (x[0], 0.0) to (x[-1], 0.0) does not overlap the baseline.

If I can determine the baseline path (coordinates) this procedure
may work.

Thanks, for your input.

Steve.

···

On 21/11/12 04:04, Benjamin Root wrote:

On Tue, Nov 20, 2012 at 12:55 AM, Stephen Gibson > <Stephen.Gibson@…634… <mailto:Stephen.Gibson@…634…>> wrote:

    I want to plot a series of (x,y) datasets similar to the
    polygon plot tutorial example (add_collection3d),
    but with a transparent facecolor and no baseline.

    Setting alpha=0.0 in the tutorial example (below)
    achieves the transparency, but the baseline remains.

    Is there a way to remove the baseline?

    Tks,

    Steve.

    from mpl_toolkits.mplot3d import Axes3D
    from matplotlib.collections import PolyCollection
    from matplotlib.colors import colorConverter
    import matplotlib.pyplot as plt
    import numpy as np

    fig = plt.figure()
    ax = fig.gca(projection='3d')

    cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.0)

    xs = np.arange(0, 10, 0.4)
    verts = []
    zs = [0.0, 1.0, 2.0, 3.0]
    for z in zs:
         ys = np.random.rand(len(xs))
         ys[0], ys[-1] = 0, 0
         verts.append(list(zip(xs, ys)))

    poly = PolyCollection(verts, facecolors = [cc('r'), cc('g'), cc('b'),
                                                cc('y')])
    #poly.set_alpha(0.7)
    ax.add_collection3d(poly, zs=zs, zdir='y')

    ax.set_xlabel('X')
    ax.set_xlim3d(0, 10)
    ax.set_ylabel('Y')
    ax.set_ylim3d(-1, 4)
    ax.set_zlabel('Z')
    ax.set_zlim3d(0, 1)

You should be able to set "edgecolors='none'" or as the same color as the facecolors in the constructor for PolyCollection to make it disappear. Unfortunately, that would apply to the entire polygon, and not just the part at the base.

Ben Root

Setting the y-values of the start and end points to zero, (x[0],0.0) and
(x[-1],0.0), forces the return baseline path to be "well defined" at y=0,
allowing it to be overlain with a second line of a neutral colour.

However, this baseline also wipes a through adjacent slice data.

= FAIL.

Steve.

···

On 21/11/12 08:38, Stephen Gibson wrote:

Unfortunately, as you state, "edgecolors='none'" also wipes the
(x,y) data line.

I tried adding an additional "erase" zero line, with "edgecolors='none'"
for each slice, but it seems the return path extends from
(x[0],y[0]) to (x[-1],y[-1]) via some intermediate point.

An additional blank (x[0], 0.0) to (x[-1], 0.0) does not overlap the baseline.

If I can determine the baseline path (coordinates) this procedure
may work.

Thanks, for your input.

Steve.

On 21/11/12 04:04, Benjamin Root wrote:

On Tue, Nov 20, 2012 at 12:55 AM, Stephen Gibson >> <Stephen.Gibson@…634… <mailto:Stephen.Gibson@…634…>> wrote:

    I want to plot a series of (x,y) datasets similar to the
    polygon plot tutorial example (add_collection3d),
    but with a transparent facecolor and no baseline.

    Setting alpha=0.0 in the tutorial example (below)
    achieves the transparency, but the baseline remains.

    Is there a way to remove the baseline?

    Tks,

    Steve.

    from mpl_toolkits.mplot3d import Axes3D
    from matplotlib.collections import PolyCollection
    from matplotlib.colors import colorConverter
    import matplotlib.pyplot as plt
    import numpy as np
    [cc('w',1.0),cc('w',1.0)
    fig = plt.figure()
    ax = fig.gca(projection='3d')

    cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.0)

    xs = np.arange(0, 10, 0.4)
    verts = []
    zs = [0.0, 1.0, 2.0, 3.0]
    for z in zs:
         ys = np.random.rand(len(xs))
         ys[0], ys[-1] = 0, 0
         verts.append(list(zip(xs, ys)))

    poly = PolyCollection(verts, facecolors = [cc('r'), cc('g'), cc('b'),
                                                cc('y')])
    #poly.set_alpha(0.7)
    ax.add_collection3d(poly, zs=zs, zdir='y')

    ax.set_xlabel('X')
    ax.set_xlim3d(0, 10)
    ax.set_ylabel('Y')
    ax.set_ylim3d(-1, 4)
    ax.set_zlabel('Z')
    ax.set_zlim3d(0, 1)

You should be able to set "edgecolors='none'" or as the same color as the facecolors in the constructor for PolyCollection to make it disappear. Unfortunately, that would apply to the entire polygon, and not just the part at the base.

Ben Root

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Sorry, for the repeated emails/noise.

There is in fact an option "closed=False" for not closing the path:

*class* `matplotlib.collections.``PolyCollection`(*verts*, *sizes=None*    ,

closed=True, **kwargs)

However, "closed=False" has no effect.

Steve.

closed=False means something else. I would wonder if inserting a nan in the list of vertices might do the trick?

Ben Root

···

On Tuesday, November 20, 2012, Stephen Gibson wrote:

Sorry, for the repeated emails/noise.

There is in fact an option "closed=False" for not closing the path:

*class* `matplotlib.collections.``PolyCollection`(*verts*, *sizes=None*    ,

closed=True, **kwargs)

However, "closed=False" has no effect.



Steve.

Ok. Adding an NaN as the last data point did not help.

However, I notice that the return path is two segments that go through (0,0).

i.e. the baseline (or return) path may actually start/finish at (0,0)

The attached image shows my data offset in y-direction by +1. The end points
have been set to y=0.5. The baseline (or return path) is the line segment that
starts at the first data point, passes through (x=0,y=0), and ends at the last
data point.

Steve.

Data.png

···

On 21/11/12 11:46, Benjamin Root wrote:

closed=False means something else. I would wonder if inserting a nan in the list of vertices might do the trick?

Ben Root

Actually, this might be related to a bug that was pointed out to me a while back that I just could not figure out. Having this example might help in narrowing down the cause. Essentially, the (0,0) vertex was being added even when it shouldn’t have been. The key difference in this example is that zdir=‘y’ is used, which causes the (0,0) vertex to refer to the x,z coordinate. Interesting…

I will have to investigate further.

Ben Root

···

On Tue, Nov 20, 2012 at 8:12 PM, Stephen Gibson <Stephen.Gibson@…634…> wrote:

Ok. Adding an NaN as the last data point did not help.

However, I notice that the return path is two segments that go through (0,0).

i.e. the baseline (or return) path may actually start/finish at (0,0)

The attached image shows my data offset in y-direction by +1. The end points

have been set to y=0.5. The baseline (or return path) is the line segment that

starts at the first data point, passes through (x=0,y=0), and ends at the last

data point.

Steve.