Re: [Matplotlib-users] removing paths inside polygon
Thanks, the clipping is working now. But as you say the weird line width issue still remains for Agg (and png, perhaps that uses Agg, I don't know...). PDF output looks correct. On 20 March 2013 05:48, Jae-Joon Lee lee.j.j...@gmail.com wrote: On Wed, Mar 13, 2013 at 2:17 AM, Andrew Dawson daw...@atm.ox.ac.ukwrote: You should see that the circle is no longer circular, and also there are weird line width issues. What I want it basically exactly like the attached without_clipping.png but with paths inside the circle removed. The reason that circle is no more circle is that simply inverting the vertices does not always results in a correctly inverted path. Instead of following line. interior.vertices = interior.vertices[::-1] You should use something like below. interior = mpath.Path(np.concatenate([interior.vertices[-2::-1], interior.vertices[-1:]]), interior.codes) It would be good if we have a method to invert a path. This will give you a circle. But the weird line width issue remains. This seems to be an Agg issue, and the line width seems to depend on the dpi. I guess @mdboom nay have some insight on this. Regards, -JJ -- Dr Andrew Dawson Atmospheric, Oceanic Planetary Physics Clarendon Laboratory Parks Road Oxford OX1 3PU, UK Tel: +44 (0)1865 282438 Email: daw...@atm.ox.ac.uk Web Site: http://www2.physics.ox.ac.uk/contacts/people/dawson -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] PGF backend and logarithmic plots
Hi, following problem arises when using the pgf backend: For the plots in my document I would like to use a sans-serif font. Because I want to use the functionality of the Tex-package siunitx (among others) I need to use either the pdf-backend with text.usetex set to True or the pgf-backend. Because I like the idea of being able to use virtually any font with XeLatex I'd prefer using the pgf-backend. However, I cannot seem to be able to convince matplotlib to use a sans-serif font for the tick-labels of my logarithmic axis. The weird thing is, that there is no problem when using linear scales. My (minimal) matplotlibrc looks like this: backend : pdf font.family : sans-serif pgf.preamble : \usepackage{sfmath} An example script to reproduce the error: #!usr/bin/env python from pylab import * y = logspace(-3,9,num=50,base=10.0) fig = figure(1) clf() myplt = fig.add_subplot(111) myplt.plot(y) myplt.set_yscale('log') savefig('test.pdf') Has anyone had similar issues or does anyone have a good idea as to what to look into? Any help would be greatly appreciated. Thanks in advance, Kalle -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Squashed axes with AxesGrid
Steven, Did you mean to switch back to AxesGrid? I thought you said that it was fixed with Grid. -Sterling On Mar 22, 2013, at 9:30AM, Steven Boada wrote: Well... I jumped the gun. To better illustrate the problem(s) I am having, I wrote a simple script that doesn't work... import pylab as pyl from mpl_toolkits.axes_grid1 import AxesGrid # make some data xdata = pyl.random(100) * 25. ydata = pyl.random(100) * 8. colordata = pyl.random(100) * 3. # make us a figure F = pyl.figure(1,figsize=(5.5,3.5)) grid = AxesGrid(F, 111, nrows_ncols=(1,2), axes_pad = 0.1, add_all=True, share_all = True, cbar_mode = 'each', cbar_location = 'top') # Plot! sc1 = grid[0].scatter(xdata, ydata, c=colordata, s=50, cmap='spectral') sc2 = grid[1].scatter(xdata, ydata, c=colordata, s=50, cmap='spectral') # Add colorbars grid.cbar_axes[0].colorbar(sc1) grid.cbar_axes[1].colorbar(sc2) grid[0].set_xlim(0,25) grid[0].set_ylim(0,8) pyl.show() And you get some squashed figures... I'll attach a png. Thanks again. Steven On Fri Mar 22 10:49:44 2013, Steven Boada wrote: Thanks JJ! That did fix my problem, but I can't say I understand what the difference is. Why does Axesgrid make them squashed while just Grid works? On Thu Mar 21 22:28:34 2013, Jae-Joon Lee wrote: It is not clear what your problem is. AxesGrid implicitly assumes aspect=1 for each axes. So, I guess your y-limits are smaller (in its span) than x-limits. If you don't want this behavior, there is no need of using the AxesGrid. Rather use Grid, or simply subplots. import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import Grid F = plt.figure(1,(5.5,3.5)) grid = Grid(F, 111, nrows_ncols=(1,3), axes_pad = 0.1, add_all=True, label_mode = 'L', ) If this is not the answer you're looking for, I recommend you to post a complete but simple script that reproduces your problem and describe the problem more explicitly. Regards, -JJ On Fri, Mar 22, 2013 at 6:03 AM, Steven Boada bo...@physics.tamu.edu mailto:bo...@physics.tamu.edu wrote: Heya List, See attached image for what I mean. Here is the grid creation bit. I can't seem to figure out what might be causing such a problem. F = pyl.figure(1,(5.5,3.5)) grid = AxesGrid(F, 111, nrows_ncols=(1,3), axes_pad = 0.1, add_all=True, label_mode = 'L', aspect=True) Should be simple enough right? -- Steven Boada Doctoral Student Dept of Physics and Astronomy Texas AM University bo...@physics.tamu.edu mailto:bo...@physics.tamu.edu -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net mailto:Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Steven Boada Doctoral Student Dept of Physics and Astronomy Texas AM University bo...@physics.tamu.edu -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Steven Boada Doctoral Student Dept of Physics and Astronomy Texas AM University bo...@physics.tamu.edu Screen Shot 2013-03-22 at 11.27.19 AM.png-- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] removing paths inside polygon
See https://github.com/matplotlib/matplotlib/pull/1846 On 03/22/2013 11:17 AM, Michael Droettboom wrote: It's puzzler. I'm looking at it now. Mike On 03/22/2013 06:33 AM, Andrew Dawson wrote: Thanks, the clipping is working now. But as you say the weird line width issue still remains for Agg (and png, perhaps that uses Agg, I don't know...). PDF output looks correct. On 20 March 2013 05:48, Jae-Joon Lee lee.j.j...@gmail.com mailto:lee.j.j...@gmail.com wrote: On Wed, Mar 13, 2013 at 2:17 AM, Andrew Dawson daw...@atm.ox.ac.uk mailto:daw...@atm.ox.ac.uk wrote: You should see that the circle is no longer circular, and also there are weird line width issues. What I want it basically exactly like the attached without_clipping.png but with paths inside the circle removed. The reason that circle is no more circle is that simply inverting the vertices does not always results in a correctly inverted path. Instead of following line. interior.vertices = interior.vertices[::-1] You should use something like below. interior = mpath.Path(np.concatenate([interior.vertices[-2::-1], interior.vertices[-1:]]), interior.codes) It would be good if we have a method to invert a path. This will give you a circle. But the weird line width issue remains. This seems to be an Agg issue, and the line width seems to depend on the dpi. I guess @mdboom nay have some insight on this. Regards, -JJ -- Dr Andrew Dawson Atmospheric, Oceanic Planetary Physics Clarendon Laboratory Parks Road Oxford OX1 3PU, UK Tel: +44 (0)1865 282438 Email: daw...@atm.ox.ac.uk mailto:daw...@atm.ox.ac.uk Web Site: http://www2.physics.ox.ac.uk/contacts/people/dawson -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Squashed axes with AxesGrid
Sorry y'all. I can see the confusion. I started with AxesGrid -- squashed. JJ suggested Grid and that fixes the scaling problems. I realized that using just plain Grid doesn't give me the nice controls over the colorbars (which I would like to have), so I wrote a simple script and emailed it back out. That did include AxesGrid. According to the manual ( http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html#axes-grid1 )... aspect By default (False), widths and heights of axes in the grid are scaled independently. If True, they are scaled according to their data limits (similar to aspect parameter in mpl). Which I read as it should scale the widths and heights should not be squashed. But what Ben is telling me (thanks for the explanation) is that isn't true. Seems like there is something simple I am just missing. Sorry for that bit of confusion. Steven On Fri Mar 22 11:39:46 2013, Benjamin Root wrote: On Fri, Mar 22, 2013 at 12:30 PM, Steven Boada bo...@physics.tamu.edu mailto:bo...@physics.tamu.edu wrote: Well... I jumped the gun. To better illustrate the problem(s) I am having, I wrote a simple script that doesn't work... import pylab as pyl from mpl_toolkits.axes_grid1 import AxesGrid # make some data xdata = pyl.random(100) * 25. ydata = pyl.random(100) * 8. colordata = pyl.random(100) * 3. # make us a figure F = pyl.figure(1,figsize=(5.5,3.5)__) grid = AxesGrid(F, 111, nrows_ncols=(1,2), axes_pad = 0.1, add_all=True, share_all = True, cbar_mode = 'each', cbar_location = 'top') # Plot! sc1 = grid[0].scatter(xdata, ydata, c=colordata, s=50, cmap='spectral') sc2 = grid[1].scatter(xdata, ydata, c=colordata, s=50, cmap='spectral') # Add colorbars grid.cbar_axes[0].colorbar(__sc1) grid.cbar_axes[1].colorbar(__sc2) grid[0].set_xlim(0,25) grid[0].set_ylim(0,8) pyl.show() And you get some squashed figures... I'll attach a png. Thanks again. Steven You used AxesGrid again, not Grid. AxesGrid implicitly applies an aspect='equal' to the subplots. This means that a unit of distance on the x-axis takes the same amount of space as the same unit of distance on the y-axis. In your example, the x axis goes from 0 to 25, while the y-axis goes from 0 to 8. When aspect='equal', the y-axis will then be about a third the size of the x-axis, because the y-limits are about a third the size of the x-limits. Ben Root -- Steven Boada Doctoral Student Dept of Physics and Astronomy Texas AM University bo...@physics.tamu.edu -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Squashed axes with AxesGrid
...and did aspect=False not give you what you want? From what I can see http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html#axes-grid1 contradicts itself, and the chart is correct and the description below incorrect. FWIW, I would expect the default to be False as well, but who am I to say? Cheers, Jody On Mar 22, 2013, at 9:52 AM, Steven Boada bo...@physics.tamu.edu wrote: Sorry y'all. I can see the confusion. I started with AxesGrid -- squashed. JJ suggested Grid and that fixes the scaling problems. I realized that using just plain Grid doesn't give me the nice controls over the colorbars (which I would like to have), so I wrote a simple script and emailed it back out. That did include AxesGrid. According to the manual ( http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html#axes-grid1 )... aspect By default (False), widths and heights of axes in the grid are scaled independently. If True, they are scaled according to their data limits (similar to aspect parameter in mpl). Which I read as it should scale the widths and heights should not be squashed. But what Ben is telling me (thanks for the explanation) is that isn't true. Seems like there is something simple I am just missing. Sorry for that bit of confusion. Steven On Fri Mar 22 11:39:46 2013, Benjamin Root wrote: On Fri, Mar 22, 2013 at 12:30 PM, Steven Boada bo...@physics.tamu.edu mailto:bo...@physics.tamu.edu wrote: Well... I jumped the gun. To better illustrate the problem(s) I am having, I wrote a simple script that doesn't work... import pylab as pyl from mpl_toolkits.axes_grid1 import AxesGrid # make some data xdata = pyl.random(100) * 25. ydata = pyl.random(100) * 8. colordata = pyl.random(100) * 3. # make us a figure F = pyl.figure(1,figsize=(5.5,3.5)__) grid = AxesGrid(F, 111, nrows_ncols=(1,2), axes_pad = 0.1, add_all=True, share_all = True, cbar_mode = 'each', cbar_location = 'top') # Plot! sc1 = grid[0].scatter(xdata, ydata, c=colordata, s=50, cmap='spectral') sc2 = grid[1].scatter(xdata, ydata, c=colordata, s=50, cmap='spectral') # Add colorbars grid.cbar_axes[0].colorbar(__sc1) grid.cbar_axes[1].colorbar(__sc2) grid[0].set_xlim(0,25) grid[0].set_ylim(0,8) pyl.show() And you get some squashed figures... I'll attach a png. Thanks again. Steven You used AxesGrid again, not Grid. AxesGrid implicitly applies an aspect='equal' to the subplots. This means that a unit of distance on the x-axis takes the same amount of space as the same unit of distance on the y-axis. In your example, the x axis goes from 0 to 25, while the y-axis goes from 0 to 8. When aspect='equal', the y-axis will then be about a third the size of the x-axis, because the y-limits are about a third the size of the x-limits. Ben Root -- Steven Boada Doctoral Student Dept of Physics and Astronomy Texas AM University bo...@physics.tamu.edu -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Jody Klymak http://web.uvic.ca/~jklymak/ -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Squashed axes with AxesGrid
Hey Jody et al. Yeah aspect = False does the trick. Thanks for the help trouble shooting. Steven On Fri Mar 22 11:59:45 2013, Jody Klymak wrote: ...and did aspect=False not give you what you want? From what I can see http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html#axes-grid1 contradicts itself, and the chart is correct and the description below incorrect. FWIW, I would expect the default to be False as well, but who am I to say? Cheers, Jody On Mar 22, 2013, at 9:52 AM, Steven Boada bo...@physics.tamu.edu wrote: Sorry y'all. I can see the confusion. I started with AxesGrid -- squashed. JJ suggested Grid and that fixes the scaling problems. I realized that using just plain Grid doesn't give me the nice controls over the colorbars (which I would like to have), so I wrote a simple script and emailed it back out. That did include AxesGrid. According to the manual ( http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html#axes-grid1 )... aspect By default (False), widths and heights of axes in the grid are scaled independently. If True, they are scaled according to their data limits (similar to aspect parameter in mpl). Which I read as it should scale the widths and heights should not be squashed. But what Ben is telling me (thanks for the explanation) is that isn't true. Seems like there is something simple I am just missing. Sorry for that bit of confusion. Steven On Fri Mar 22 11:39:46 2013, Benjamin Root wrote: On Fri, Mar 22, 2013 at 12:30 PM, Steven Boada bo...@physics.tamu.edu mailto:bo...@physics.tamu.edu wrote: Well... I jumped the gun. To better illustrate the problem(s) I am having, I wrote a simple script that doesn't work... import pylab as pyl from mpl_toolkits.axes_grid1 import AxesGrid # make some data xdata = pyl.random(100) * 25. ydata = pyl.random(100) * 8. colordata = pyl.random(100) * 3. # make us a figure F = pyl.figure(1,figsize=(5.5,3.5)__) grid = AxesGrid(F, 111, nrows_ncols=(1,2), axes_pad = 0.1, add_all=True, share_all = True, cbar_mode = 'each', cbar_location = 'top') # Plot! sc1 = grid[0].scatter(xdata, ydata, c=colordata, s=50, cmap='spectral') sc2 = grid[1].scatter(xdata, ydata, c=colordata, s=50, cmap='spectral') # Add colorbars grid.cbar_axes[0].colorbar(__sc1) grid.cbar_axes[1].colorbar(__sc2) grid[0].set_xlim(0,25) grid[0].set_ylim(0,8) pyl.show() And you get some squashed figures... I'll attach a png. Thanks again. Steven You used AxesGrid again, not Grid. AxesGrid implicitly applies an aspect='equal' to the subplots. This means that a unit of distance on the x-axis takes the same amount of space as the same unit of distance on the y-axis. In your example, the x axis goes from 0 to 25, while the y-axis goes from 0 to 8. When aspect='equal', the y-axis will then be about a third the size of the x-axis, because the y-limits are about a third the size of the x-limits. Ben Root -- Steven Boada Doctoral Student Dept of Physics and Astronomy Texas AM University bo...@physics.tamu.edu -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Jody Klymak http://web.uvic.ca/~jklymak/ -- Steven Boada Doctoral Student Dept of Physics and Astronomy Texas AM University bo...@physics.tamu.edu -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users