Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## [Matplotlib-users] matplotlib 3D: interpolated shading

 [Matplotlib-users] matplotlib 3D: interpolated shading From: Holger Brandsmeier - 2011-09-30 09:28:03 ```Dear List, is it possible to not only assign once color per polygon that is plotted, but one color for each vertex, so that the result looks like a properly smooth function. Even if I sample the points closely enough, in the current approach in almost all of your examples you always see the underlying grid (plus it gets very slow in 3D). I don't really care much if you interpolate the colors on the 2D projection of the polygon or on the real 3D polygon, just any color interpolation is better than none. What do you actually understand behind the "antialiasing" parameter of 34D plots. It just puzzles me to have such a concept without have a concept of pixel shading (and thus an easy way for the above interpolation). I noticed that even 2D plots from matplot lib are very pixel dominated: http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo.html But there is the function imshow which doesn't have this artifacts: http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo2.html So is it possible to do something like imshow for 3D as well? -Holger ```

 [Matplotlib-users] matplotlib 3D: interpolated shading From: Holger Brandsmeier - 2011-09-30 09:28:03 ```Dear List, is it possible to not only assign once color per polygon that is plotted, but one color for each vertex, so that the result looks like a properly smooth function. Even if I sample the points closely enough, in the current approach in almost all of your examples you always see the underlying grid (plus it gets very slow in 3D). I don't really care much if you interpolate the colors on the 2D projection of the polygon or on the real 3D polygon, just any color interpolation is better than none. What do you actually understand behind the "antialiasing" parameter of 34D plots. It just puzzles me to have such a concept without have a concept of pixel shading (and thus an easy way for the above interpolation). I noticed that even 2D plots from matplot lib are very pixel dominated: http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo.html But there is the function imshow which doesn't have this artifacts: http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo2.html So is it possible to do something like imshow for 3D as well? -Holger ```
 Re: [Matplotlib-users] matplotlib 3D: interpolated shading From: Benjamin Root - 2011-09-30 15:07:16 Attachments: Message as HTML ```On Fri, Sep 30, 2011 at 4:27 AM, Holger Brandsmeier < holger.brandsmeier@...> wrote: > Dear List, > > is it possible to not only assign once color per polygon that is > plotted, but one color for each vertex, so that the result looks like > a properly smooth function. Even if I sample the points closely > enough, in the current approach in almost all of your examples you > always see the underlying grid (plus it gets very slow in 3D). I don't > really care much if you interpolate the colors on the 2D projection of > the polygon or on the real 3D polygon, just any color interpolation is > better than none. > What values for rstride and cstride are you using? By default, plot_surface() will sample every 10th point of the data array (for performance reasons). Also, color interpoltion can be turned on by setting shade to True. > > What do you actually understand behind the "antialiasing" parameter of > 34D plots. It just puzzles me to have such a concept without have a > concept of pixel shading (and thus an easy way for the above > interpolation). > > Again, plot_surface() has a shade kwarg. Use it and let me know if it meets your expectations. > I noticed that even 2D plots from matplot lib are very pixel dominated: > http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo.html > > But there is the function imshow which doesn't have this artifacts: > http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo2.html > > for pcolor(), you can set the antialiaseds kwarg to True. The only reason why imshow looks good in the second example is because the interpolation was set to bilinear, and I think that automatically sets antialiasing to True. > So is it possible to do something like imshow for 3D as well? > > imshow() in 2d was not designed in such a way to yet be used in 3d, but I think there is already a feature request filed for that. Try shade=True for plot_surface() and see how that looks for you. Cheers! Ben Root ```
 Re: [Matplotlib-users] matplotlib 3D: interpolated shading From: Holger Brandsmeier - 2011-10-05 18:21:43 ```Ben, I would be very happy to have this functionality. I think this would also make the 3D plots in the examples that matplot provides look a good deal nicer. Let me know if you have any updates on this. -Holger On Mon, Oct 3, 2011 at 21:18, Benjamin Root wrote: > > > On Fri, Sep 30, 2011 at 11:33 AM, Holger Brandsmeier > wrote: >> >> Ben, >> >> On Fri, Sep 30, 2011 at 17:06, Benjamin Root wrote: >> > What values for rstride and cstride are you using?  By default, >> > plot_surface() will sample every 10th point of the data array (for >> > performance reasons).  Also, color interpoltion can be turned on by >> > setting >> > shade to True. >> >> I beleive I start to understand the underlying logic. If no color map >> is set and shading and antialiazing is set,  then indeed the surface >> is nicely and smoothly displayed. When I provide a color map, then I >> seem to be able to assign one color for the whole polygon. I also find >> something like that in the code. >> >> In my case I want the z-coordinate to determine the color. I want to >> use a colormap like jet and no transparency. If I don't use the >> colormap argument, then I get shading, however everything is blue with >> shading depending on a lightsource.I don't really need a lightsource, >> but I would like non-constant colors per polygon. >> > > Yes, you have the logic correct (and probably better explained than I could > have done).  This actually was an issue raised a couple of months ago in a > bit of a different context, but the solution wasn't entirely clear at that > point.  However, looking at the code again (remember, I didn't write it > originally, and it had next to no comments), I think I see a fairly simple > solution.  If I allow for the user to specify a light source of None, then I > could feed the data through a different function to "shade" the surface.  I > will look into doing that, but it won't make it into the v1.1.0 release > (slated for tomorrow). > > Cheers! > Ben Root > > -- Holger Brandsmeier, SAM, ETH Zürich http://www.sam.math.ethz.ch/people/bholger ```
 Re: [Matplotlib-users] matplotlib 3D: interpolated shading From: Ethan Gutmann - 2011-10-05 20:23:32 ```Holger, for what it is worth, you can hack this fairly easily. Run the code twice once with colors, once with shading. Take the output from both as images, the convert both images to HSV, the recombine the HS components from the color version with the V component of the shaded version. I haven't done this in matplotlib, but it worked great for me in IDL. On Oct 5, 2011, at 1:23 PM, Holger Brandsmeier wrote: > Ben, > > I would be very happy to have this functionality. I think this would > also make the 3D plots in the examples that matplot provides look a > good deal nicer. > > Let me know if you have any updates on this. > > -Holger > > On Mon, Oct 3, 2011 at 21:18, Benjamin Root wrote: >> >> >> On Fri, Sep 30, 2011 at 11:33 AM, Holger Brandsmeier >> wrote: >>> >>> Ben, >>> >>> On Fri, Sep 30, 2011 at 17:06, Benjamin Root wrote: >>>> What values for rstride and cstride are you using? By default, >>>> plot_surface() will sample every 10th point of the data array (for >>>> performance reasons). Also, color interpoltion can be turned on by >>>> setting >>>> shade to True. >>> >>> I beleive I start to understand the underlying logic. If no color map >>> is set and shading and antialiazing is set, then indeed the surface >>> is nicely and smoothly displayed. When I provide a color map, then I >>> seem to be able to assign one color for the whole polygon. I also find >>> something like that in the code. >>> >>> In my case I want the z-coordinate to determine the color. I want to >>> use a colormap like jet and no transparency. If I don't use the >>> colormap argument, then I get shading, however everything is blue with >>> shading depending on a lightsource.I don't really need a lightsource, >>> but I would like non-constant colors per polygon. >>> >> >> Yes, you have the logic correct (and probably better explained than I could >> have done). This actually was an issue raised a couple of months ago in a >> bit of a different context, but the solution wasn't entirely clear at that >> point. However, looking at the code again (remember, I didn't write it >> originally, and it had next to no comments), I think I see a fairly simple >> solution. If I allow for the user to specify a light source of None, then I >> could feed the data through a different function to "shade" the surface. I >> will look into doing that, but it won't make it into the v1.1.0 release >> (slated for tomorrow). >> >> Cheers! >> Ben Root >> >> > > > > -- > Holger Brandsmeier, SAM, ETH Zürich > http://www.sam.math.ethz.ch/people/bholger > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ```