|
From: Zoltán V. <zv...@gm...> - 2012-01-08 22:05:33
|
Hi All,
I wanted to make a surface plot with some phong on it. I can generate
the colour map without any problems, but the snag is that no matter what
I do, the resulting plot is always transparent. It there a way to set
the patch colour to a true solid colour?
Here is a piece of my code (without the phong)
<snip>
colors = np.empty(X.shape, tuple)
for y in range(ylen):
for x in range(xlen):
colors[x, y] = (0, 0, 1, 1)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=colors,
linewidth=0.0, antialiased=True)
</snip>
As far as I understand, this should generate a solid blue surface, but
this is not what happens. Any hints or solutions?
Cheers,
Zoltán
|
|
From: Benjamin R. <ben...@ou...> - 2012-01-09 16:05:16
|
2012/1/8 Zoltán Vörös <zv...@gm...> > colors = np.empty(X.shape, tuple) > for y in range(ylen): > for x in range(xlen): > colors[x, y] = (0, 0, 1, 1) > > surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=colors, > linewidth=0.0, antialiased=True) > Is the issue that you have transparent lines between the faces? Set the "shade" kwarg to True and the "antialiased" kwarg to False. If the shading is not what you want, it has been a feature request to implement the smooth coloring that shading does, but without a lightsource. I have yet to do this, and there have been some attempts to get this right, but nothing finalized yet. Contributions would be welcomed! Ben Root |
|
From: Zoltán V. <zv...@gm...> - 2012-01-09 16:28:28
|
Thanks for the reply! > > surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, > facecolors=colors, > linewidth=0.0, antialiased=True) > > > Is the issue that you have transparent lines between the faces? Set > the "shade" kwarg to True and the "antialiased" kwarg to False. The problem is that the faces themselves are transparent. But if I set shade to False, it becomes solid, so that must be the solution. > If the shading is not what you want, it has been a feature request to > implement the smooth coloring that shading does, but without a > lightsource. I have yet to do this, and there have been some attempts > to get this right, but nothing finalized yet. Contributions would be > welcomed! OK, I will try to get this done and send you an implementation. Cheers, Zoltán |
|
From: Benjamin R. <ben...@ou...> - 2012-01-09 16:31:16
|
2012/1/9 Zoltán Vörös <zv...@gm...> > Thanks for the reply! > > surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=colors, >> linewidth=0.0, antialiased=True) >> > > Is the issue that you have transparent lines between the faces? Set the > "shade" kwarg to True and the "antialiased" kwarg to False. > > The problem is that the faces themselves are transparent. But if I set > shade to False, it becomes solid, so that must be the solution. > > If the shading is not what you want, it has been a feature request to > implement the smooth coloring that shading does, but without a > lightsource. I have yet to do this, and there have been some attempts to > get this right, but nothing finalized yet. Contributions would be welcomed! > > OK, I will try to get this done and send you an implementation. > Cheers, > Zoltán > What version of mpl are you using? For me (on master) I never get transparent faces. Ben Root |
|
From: Zoltán V. <zv...@gm...> - 2012-01-09 16:41:29
|
On 01/09/2012 05:30 PM, Benjamin Root wrote:
> The problem is that the faces themselves are transparent. But if I set
> shade to False, it becomes solid, so that must be the solution.
>
>
>
> What version of mpl are you using? For me (on master) I never get
> transparent faces.
I have 1.0.1 that comes with ubuntu. I was considering installing 1.1,
but then I saw that the gtk backend is not supported, so I decided
against it.
By the way, here is an example of the transparent faces (I think it
won't show on the mailing list). I can definitely see through the
surface. The code I used is
for y in range(ylen):
for x in range(xlen):
colors[x, y] = (1, 0.0, 1, 1.)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=colors,
linewidth=0.1, antialiased=False, shade=True)
|
|
From: Benjamin R. <ben...@ou...> - 2012-01-09 16:47:06
|
2012/1/9 Zoltán Vörös <zv...@gm...> > > On 01/09/2012 05:30 PM, Benjamin Root wrote: > > The problem is that the faces themselves are transparent. But if I set > shade to False, it becomes solid, so that must be the solution. > >> >> > What version of mpl are you using? For me (on master) I never get > transparent faces. > > I have 1.0.1 that comes with ubuntu. I was considering installing 1.1, but > then I saw that the gtk backend is not supported, so I decided against it. > > When we said that GTK is not supported, (1) is not an official decision, I think, (2) we mean the pure GTK *backend*. We fully support the GTKAgg backend, which is superior to the GTK backend in every way. Please try v1.1.0 before continuing. There were many important changes to mplot3d between v1.0.1 and v1.1.0. Ben Root |
|
From: Zoltán V. <zv...@gm...> - 2012-01-09 17:28:31
|
On 01/09/2012 05:46 PM, Benjamin Root wrote: > When we said that GTK is not supported, (1) is not an official > decision, I think, (2) we mean the pure GTK *backend*. We fully > support the GTKAgg backend, which is superior to the GTK backend in > every way. Please try v1.1.0 before continuing. There were many > important changes to mplot3d between v1.0.1 and v1.1.0. Indeed, that was the case. The surface plot works as advertised now. Thanks for helping out with this! Once I have a viable code for phonging, I will send it to you in a personal mail. Cheers, Zoltán |
|
From: Ethan G. <eth...@gm...> - 2012-01-09 22:51:15
|
Along these lines, it looks to me like plot_surface is not shading when I would expect it to (maybe I just have the wrong expectations?)
I would expect the following to create a surface with colors from the colormap but shading from a lightsource.
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet,shade=True)
However, axes3d.py requires facecolors to be set in order to generate facecolors to shade...
mpl_toolkits/mplot3d/axes3d.py
line 1378-1380 mpl v1.1.0
# Shade the data
if shade and cmap is not None and fcolors is not None:
fcolors = self._shade_colors_lightsource(Z, cmap, lightsource)
should the if statement be:
if shade and cmap is not None and fcolors is None:
I'm not sure if this will screw anything else up, but it makes a lot more sense to me as an API. Maybe there are other reasons to require facecolors to be set?
Ethan
On Jan 9, 2012, at 10:28 AM, Zoltán Vörös wrote:
>
>
> On 01/09/2012 05:46 PM, Benjamin Root wrote:
>> When we said that GTK is not supported, (1) is not an official
>> decision, I think, (2) we mean the pure GTK *backend*. We fully
>> support the GTKAgg backend, which is superior to the GTK backend in
>> every way. Please try v1.1.0 before continuing. There were many
>> important changes to mplot3d between v1.0.1 and v1.1.0.
> Indeed, that was the case. The surface plot works as advertised now.
> Thanks for helping out with this! Once I have a viable code for
> phonging, I will send it to you in a personal mail.
> Cheers,
> Zoltán
>
> ------------------------------------------------------------------------------
> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
> infrastructure or vast IT resources to deliver seamless, secure access to
> virtual desktops. With this all-in-one solution, easily deploy virtual
> desktops for less than the cost of PCs and save 60% on VDI infrastructure
> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
|
|
From: Benjamin R. <ben...@ou...> - 2012-01-09 23:17:49
|
On Monday, January 9, 2012, Ethan Gutmann <eth...@gm...> wrote: > Along these lines, it looks to me like plot_surface is not shading when I would expect it to (maybe I just have the wrong expectations?) > > I would expect the following to create a surface with colors from the colormap but shading from a lightsource. > > surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet,shade=True) > > However, axes3d.py requires facecolors to be set in order to generate facecolors to shade... > > mpl_toolkits/mplot3d/axes3d.py > line 1378-1380 mpl v1.1.0 > > # Shade the data > if shade and cmap is not None and fcolors is not None: > fcolors = self._shade_colors_lightsource(Z, cmap, lightsource) > > should the if statement be: > if shade and cmap is not None and fcolors is None: > > I'm not sure if this will screw anything else up, but it makes a lot more sense to me as an API. Maybe there are other reasons to require facecolors to be set? > > Ethan No, you are right. This is roughly the requested feature I was talking about. There are multiple features in plot_surface() that are entwined and I would like to figure out how to separate them and allow users to pick and choose. Features I have identified: Coloring edgelines (complicated to determine what color) Coloring based on colormap Coloring based on user-spec facecolors Shading the colors (may or may not include edge lines) Interpolating facecolors (for edgelines, IIRC) These are inter-dependent and need to be made orthogonal. Note, all of this is from memory, details might differ. Cheers! Ben Root |