|
From: Stephen G. <Ste...@an...> - 2012-11-20 06:14:50
|
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)
|
|
From: Benjamin R. <ben...@ou...> - 2012-11-20 17:05:08
|
On Tue, Nov 20, 2012 at 12:55 AM, Stephen Gibson
<Ste...@an...>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
|
|
From: Stephen G. <Ste...@an...> - 2012-11-20 21:38:59
|
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
> <Ste...@an... <mailto:Ste...@an...>> 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
>
|
|
From: Stephen G. <Ste...@an...> - 2012-11-20 22:59:48
|
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
>> <Ste...@an... <mailto:Ste...@an...>> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
|
|
From: Stephen G. <Ste...@an...> - 2012-11-20 23:52:42
|
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. |
|
From: Benjamin R. <ben...@ou...> - 2012-11-21 00:47:04
|
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. > closed=False means something else. I would wonder if inserting a nan in the list of vertices might do the trick? Ben Root |
|
From: Stephen G. <Ste...@an...> - 2012-11-21 01:13:03
Attachments:
Data.png
|
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. 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 |
|
From: Benjamin R. <ben...@ou...> - 2012-11-26 22:09:49
|
On Tue, Nov 20, 2012 at 8:12 PM, Stephen Gibson <Ste...@an...>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. > > 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 |
|
From: Guido A. <gui...@gm...> - 2013-10-31 13:45:15
|
Benjamin Root <ben.root@...> writes: > > > On Tue, Nov 20, 2012 at 8:12 PM, Stephen Gibson <Stephen.Gibson- FCV...@pu...> 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. > > > 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 > > > > > -------------------------------------------------------------------------- ---- > 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@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > Hi, I have exactly the same problem described here. Is there any solution to turn off the baseline in the polycollection? Cheers, Guido |
|
From: Benjamin R. <ben...@ou...> - 2013-10-31 14:10:26
|
On Thu, Oct 31, 2013 at 9:43 AM, Guido Avvisati <gui...@gm...>wrote: > Benjamin Root <ben.root@...> writes: > > > > > > > On Tue, Nov 20, 2012 at 8:12 PM, Stephen Gibson <Stephen.Gibson- > FCV...@pu...> 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. > > > > > > 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 > > > > > > > > > > > -------------------------------------------------------------------------- > ---- > > 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@... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > Hi, > > I have exactly the same problem described here. Is there any solution to > turn off the baseline in the polycollection? > > Cheers, > Guido > > > There was a pull request that was put together about 6 months ago that I think fixed the problem, IIRC, but it broke the API and the submitter eventually retracted the PR because it didn't seem like the right solution. The problem is extremely nuanced and there is no clear solution, unfortunately. The general idea is that the path codes are not being stored with the vertices because the underlying object holding that data is a Path (so the 3D vertices are stored separately, and as such, the list of vertices diverges from the list of path codes). Perhaps, if there was a way to make Path objects be able to hold 3D vertices, we might be able to solve this issue once and for all? Ben Root |