Re: [Matplotlib-users] Matching shading on surfaces
Thanks Ben. I had tried turning off the shading but that makes it impossible to see the features of the surface. I ended up combining the surface values and resampling with scipy.interpolate.griddata so that I have a single surface. Derek On Fri, Dec 6, 2013 at 12:23 PM, Benjamin Root wrote: > Shading is a bit complicated in plot_surface(). In your particular case, > it is simply shading based on the results of calculating the normal vector > of each facet on the surface. It then normalizes the shading it has to do > based on what it has to get the full dynamic. This is why your image looks > the way it does (plus, there might be an issue where the normals for one of > your pieces is pointed inward instead of outward, probably due to the order > of the datapoints for the surface). > > You can turn off shading altogether by simply passing shade=False as a > keyword argument to plot_surface(). > > I hope that helps! > Ben Root > > > > On Fri, Dec 6, 2013 at 12:43 PM, Derek Thomas wrote: > >> I have a surface that is defined in four distinct sections. The sections >> are continuous and at least C^1 smooth at the interface. When I plot this >> in 3D with matplotlib, each section is shaded differently. Is it possible >> to make the shading uniform? I have attached a figure. The main goal is >> to make this look like one continuous surface. Thanks, >> >> Derek >> >> >> -- >> Sponsored by Intel(R) XDK >> Develop, test and display web and hybrid apps with a single code base. >> Download it for free now! >> >> http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk >> ___ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > -- Sponsored by Intel(R) XDK Develop, test and display web and hybrid apps with a single code base. Download it for free now! http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Affine2D on scatter
I posted a related question on stackoverflow (http://stackoverflow.com/questions/15815862/apply-affine-transform-to-quiver-in-python-matplotlib) but I've produced a simple enough example with strange results that I think it merits attention here. I'm trying to apply affine transforms to quiver and scatter plots. In all cases that I've considered, the scatter and quiver plots transform opposite the regular plot. Here's a minimal case: import matplotlib as mpl from pylab import figure, subplot, plot, scatter, show, axis figure() ax = subplot(111) base_trans = ax.transData tr = mpl.transforms.Affine2D(matrix = array([[1,1,0],[0,1,0],[0,0,1]])) + base_trans plot( [1,2,3], [1,2,3], 'k.', transform = tr ) scatter( [1,2,3], [1,2,3], c = 'k', marker = 'D', transform = tr ) axis([0,7,0,7]) show() Thanks, Derek -- Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Affine2D on scatter
I get a different result. On Thu, Apr 4, 2013 at 9:25 AM, Phil Elson wrote: > Hi Derek, > > What are we looking at here? > > The following code: > > import matplotlib.pyplot as plt > import matplotlib.transforms as mtrans > import numpy as np > > plt.figure() > ax = plt.subplot(111) > base_trans = ax.transData > mtx = np.array([[1,1,0], > [0,1,0], > [0,0,1]]) > tr = mtrans.Affine2D(matrix=mtx) + base_trans > > plt.plot([1,2,3], [1,2,3], 'gray', transform=tr) > plt.scatter([1,2,3], [1,2,3], c='k', marker='D', transform=tr) > plt.show() > > produces the following plot on v1.2.0: > [image: Inline images 1] > Is this unexpected or are you getting a different result to me? > > Regards, > > > > On 4 April 2013 17:06, Derek Thomas wrote: > >> I posted a related question on stackoverflow >> ( >> http://stackoverflow.com/questions/15815862/apply-affine-transform-to-quiver-in-python-matplotlib >> ) >> but I've produced a simple enough example with strange results that I >> think it merits attention here. I'm trying to apply affine transforms >> to quiver and scatter plots. In all cases that I've considered, the >> scatter and quiver plots transform opposite the regular plot. Here's >> a minimal case: >> >> import matplotlib as mpl >> from pylab import figure, subplot, plot, scatter, show, axis >> >> figure() >> ax = subplot(111) >> base_trans = ax.transData >> tr = mpl.transforms.Affine2D(matrix = >> array([[1,1,0],[0,1,0],[0,0,1]])) + base_trans >> >> >> plot( [1,2,3], [1,2,3], 'k.', transform = tr ) >> scatter( [1,2,3], [1,2,3], c = 'k', marker = 'D', transform = tr ) >> axis([0,7,0,7]) >> show() >> >> Thanks, >> >> Derek >> >> >> -- >> Minimize network downtime and maximize team effectiveness. >> Reduce network management and security costs.Learn how to hire >> the most talented Cisco Certified professionals. Visit the >> Employer Resources Portal >> http://www.cisco.com/web/learning/employer_resources/index.html >> ___ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > <><>-- Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Affine2D on scatter
Here's the output. I'm running OS X 10.8.3. I installed matplotlib from homebrew. $HOME=/Users/dect CONFIGDIR=/Users/dect/.matplotlib matplotlib data path /usr/local/lib/python2.7/site-packages/matplotlib/mpl-data loaded rc file /usr/local/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc matplotlib version 1.2.0 verbose.level helpful interactive is False platform is darwin Using fontManager instance from /Users/dect/.matplotlib/fontList.cache backend MacOSX version unknown >>> mpl.__file__ '/usr/local/lib/python2.7/site-packages/matplotlib/__init__.pyc' >>> mpl.get_backend() 'MacOSX' >>> mpl.__version__ '1.2.0' >>> mpl.get_configdir() '/Users/dect/.matplotlib' On Fri, Apr 5, 2013 at 2:07 AM, Phil Elson wrote: > Thanks Derek & John. > > Very strange. Here's my setup: > >>>> import matplotlib >>>> matplotlib.__version__ > '1.2.0' >>>> matplotlib.get_backend() > 'TkAgg' > > > Would you mind providing all of the relevant details suggested in > http://matplotlib.org/faq/troubleshooting_faq.html#troubleshooting, along > with the code to reproduce the problem in a new github issue? > > Once I have all of the necessary details, I'd be happy to have a look into > this to see if I can find a solution. > > Cheers, > > Phil > > > > On 5 April 2013 02:02, John Gleeson wrote: >> >> >> On 2013-04-04, at 10:51 AM, Derek Thomas wrote: >> >>> ...screen capture of the display... >>> >> >> >> Derek, >> >> I just tried Phil's version of the code on my Mac (MP 1.2.0), and I see >> exactly the same problem as in your grab.tiff. This is using the default >> TkAgg backend. >> >> I happen to have built MP 1.2.0 with the Qt4 backend option. When I >> prepend the lines >> >> from matplotlib import use >> use("QT4Agg") >> >> to use Qt4, I get the expected (correct) display output. >> >> Apparently this is a bug somewhere in the chain TkAgg/Tkinter/Tk. >> >> John >> > -- Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Save pdf with plot_surface
This may be known, but the following modified example from http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html fails with a TypeError at matplotlib/backends/backend_pdf.pyc in draw_path_collection. Is it possible to save pdf files with surface plots? from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm from matplotlib.ticker import LinearLocator, FormatStrFormatter import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.gca(projection='3d') X = np.arange(-5, 5, 0.25) Y = np.arange(-5, 5, 0.25) X, Y = np.meshgrid(X, Y) R = np.sqrt(X**2 + Y**2) Z = np.sin(R) surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False) ax.set_zlim(-1.01, 1.01) ax.zaxis.set_major_locator(LinearLocator(10)) ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f')) fig.colorbar(surf, shrink=0.5, aspect=5) fig.savefig('test.pdf') plt.show() -- Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Save pdf with plot_surface
I was able to fix this by uninstalling the matplotlib from homebrew and installing with pip. On Sat, Apr 20, 2013 at 9:33 AM, Derek Thomas wrote: > This may be known, but the following modified example from > http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html fails with a > TypeError at matplotlib/backends/backend_pdf.pyc in draw_path_collection. > Is it possible to save pdf files with surface plots? > > from mpl_toolkits.mplot3d import Axes3D > from matplotlib import cm > from matplotlib.ticker import LinearLocator, FormatStrFormatter > import matplotlib.pyplot as plt > import numpy as np > > fig = plt.figure() > ax = fig.gca(projection='3d') > X = np.arange(-5, 5, 0.25) > Y = np.arange(-5, 5, 0.25) > X, Y = np.meshgrid(X, Y) > R = np.sqrt(X**2 + Y**2) > Z = np.sin(R) > surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, > linewidth=0, antialiased=False) > ax.set_zlim(-1.01, 1.01) > > ax.zaxis.set_major_locator(LinearLocator(10)) > ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f')) > > fig.colorbar(surf, shrink=0.5, aspect=5) > fig.savefig('test.pdf') > plt.show() > > -- Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users