Re: [Matplotlib-users] Integer equal-width bins for histograms
Am Thu, 29 May 2014 14:14:52 -0700 schrieb Antony Lee antony@berkeley.edu: Hi, When histogramming integer data, is there an easy way to tell matplotlib that I want a certain number of bins, and each bin to cover an equal number of integers (except possibly the last one)? (in order to avoid having some bins higher than others merely because they cover more integers) I know I can pass in an explicit bins array (something like list(range(min, max, (max-min)//n)) + max) but I was hoping for something simpler, like hist(data, nbins=42, equal_integer_coverage=True). Best, Antony Int data is discrete. For discrete variables you don't need bins, you don't estimate the frequency distribution you know it exactly by counting. Of course you could do that with the hist function: pl.hist(r, np.arange(min(r)-0.5, max(r)+1.5), histtype='step') -- Time is money. Stop wasting it! Get your web API in 5 minutes. www.restlet.com/download http://p.sf.net/sfu/restlet ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Basemap.drawgreatcircle() map border
Hey, I know that you're not supposed to draw a greatcircle with Basemaps drawgreatcircle() when it will hit the border of the map. But I think it works pretty well except for the attempt to connect the line (see horizontal lines in [1]). Is there a way to not get these horizontal lines? Does someone has an idea how to hack drawgreatcircle() accordingly? Brute force if wanted, I don't care so much about efficiency at this point. Thanks for reading and possibly helping ;-) Cheers, Yoshi [1]: http://rokuko.net/test.png -- November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] streamplots in axesgrid
Sun, 6 Oct 2013 15:41:07 -0500 Tony Yu tsy...@gmail.com: The return value for streamplot is a bit hacked together. Its just a simple object containing a line collection and an arrow collection. Instead of passing the set of collections, just pass one of the collections to the colorbar. For example: sset = grid[i].streamplot(XPTS, YPTS, zx, zy, color=zr) grid.cbar_axes[i].colorbar(sset.lines) Does that work for you? works like a charm - thank you! best regards, Yoshi -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60134791iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] streamplots in axesgrid
Hey, I'm trying to plot streamplots into an axesgrid object with something like: fig = pl.figure(1, (13, 20)) grid = AxesGrid(fig, 111, nrows_ncols = (3, 2), axes_pad = 0.6, cbar_location = 'top', cbar_mode = 'each', cbar_size = '2%', cbar_pad = '1%', ) [...] norm = mpl.colors.LogNorm(vmin=1, vmax=5000) im = grid[i].streamplot(XPTS, YPTS, zx, zy, color=zr, arrowsize=.001, norm=norm) grid.cbar_axes[i].colorbar(im) [...] and then it failes with: Traceback (most recent call last): File ./results.py, line 96, in module grid.cbar_axes[i].colorbar(im) File /usr/lib/python2.7/site-packages/mpl_toolkits/axes_grid1/axes_grid.py, line 85, in colorbar cb = Colorbar(self, mappable, orientation=orientation, **kwargs) File /usr/lib/python2.7/site-packages/mpl_toolkits/axes_grid1/colorbar.py, line 706, in __init__ mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax AttributeError: 'StreamplotSet' object has no attribute 'autoscale_None' can't I use streamplots in axesgrid? If I comment out the colorbar for the streamplot colors it works ... Is this a bug? Is there a right way to do it? Is there a work around? Many thanks in advance! Regards, Yoshi -- October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60133471iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] EPS backend
I'm having problems recently with printing EPS figures created by matplotlib. To me this is strange because printing postscript should just work in my opinion. My most recent example is a Basemap thing with AxesGrid. Basically the idea was to have six maps nicely arranged on a DIN A4 paper for printout. The EPS looked nice on my notebook but printing them on our freshly leased printers at the institute failed in the middle of the fifth map (six maps in total). I have Ghostscript 9.07 and it turned out that this EPS stopped working with just one earlier version (a college with Ghostscript 9.06 could not open the EPS or more correct Ghostview failed in the middle of map number five). I expect such a Ghostscript version thing to be the problem also with the printer. If that is the case don't you think that's ridiculous? Isn't at least some legacy support wanted? I don't have a minimal example yet, but I could try to create one next week if the need is there. The above mentioned thing was something along the lines of: ... import matplotlib.pyplot as pl from mpl_toolkits.basemap import Basemap from mpl_toolkits.axes_grid1 import AxesGrid # loading data ... fig = pl.figure(1, (16,19)) grid = AxesGrid(fig, 111, nrows_ncols = (3, 2), axes_pad = 0.3, cbar_location = 'top', cbar_mode = 'each', cbar_size = '3%', cbar_pad = '1%', ) for i in range(6): bmap = Basemap(projection='aeqd', ..., ax=grid[i]) ... pl.savefig('sixer.eps', bbox_inches='tight') Best regards, Yoshi -- How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] EPS backend
Fr, 7 Jun 2013 10:13:26 -0400 Michael Droettboom md...@stsci.edu: Have you tried setting ps.usedistiller to False, or xpdf? There have been problems using Ghostscript as a distiller with recent versions of Ghostscript. No, I didn't try. Thanks for the hint, I will test that. We'll need a minimal example, or at least a copy of the PS file to investigate this further, however. Also, what platform, version of matplotlib and Python are you using? If I keep everything on my system linux with python 2.7.5 and matplotlib 1.2.1 it works fine. Problems arise if I move the EPS to an older system or the printing. I will have access to these machines on Tue. I will try to create a minimal example then. Best regards, Yoshi -- How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plot_date with multiple subplots
i use something like that: from datetime import datetime, timedelta import matplotlib.pyplot as pl import matplotlib.ticker as ticker import matplotlib.dates as mdates dates1 = [datetime(2005,5,11)+n*timedelta(days=1) for n in range(500)] dates2 = [datetime(... ax1 = pl.subplot(2,1,1) ax1.plot(dates1, y1, 'r') ax1.fmt_xdata = mdates.DateFormatter('%Y-%m-%d') ax2 = pl.subplot(2,1,2) ax2.plot(dates2, ... that's what you want? regards, yoshi -- 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. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] contourf cmap.set_under
following the example [1] i can't get the colorbar extend colors to show properly. here is what i did: import matplotlib.pyplot as plt import matplotlib.cm as cm levels = np.linspace(.01,.69,10) ... im = plt.contourf(x, y, z, levels, extend='both', cmap=cm.BuPu) im.cmap.set_under('yellow') im.cmap.set_over('cyan') what am i missing? thank you, best regards, yoshi [1] http://matplotlib.sourceforge.net/examples/pylab_examples/contourf_demo.html PS if i have something like: mymap = matplotlib.colors.LinearSegmentedColormap('MyMap', cmdat, 256) mymap.set_under('yellow') mymap.set_over('cyan') also doesn't work ... -- 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. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] axes_grid1 and colorbar ticks
does someone knows how to specify ticks for a colorbar inside axesgrid? the following does not work as expected: from mpl_toolkits.axes_grid1 import AxesGrid ticks = [.01, .25, .5, .75, .99] grid = AxesGrid() [...] grid.cbar_axes[i].colorbar(im, ticks=ticks) i'm thankfull for any pointers, yoshi -- 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. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] axes_grid1 and colorbar ticks
+--- Jae-Joon Lee ---+ This seems to be a bug that need to be fixed. Meanwhile, use locator parameter as below. cbar = grid.cbar_axes[0].colorbar(im, locator=ticks) that works, thank you! best regards, yoshi -- 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. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Basemap AxesGrid
grid = AxesGrid(fig, 132, nrows_ncols = (3, 2), axes_pad = 0.1, cbar_location = top, cbar_mode=single, ) solved by using: grid = AxesGrid(fig, 111, ...) best regards, yoshi -- RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Basemap AxesGrid
+-- Benjamin Root ---+ Why not something like this: fig = plt.figure() grid = AxesGrid(...) bm = Basemap(...) for ax in grid : x, y = bm(lon, lat) ax.scatter(x, y, vmin=globalmin, vmax=globalmax) I do variations of this all the time. Thanks for the tip, this is not going to work because Basemap() draws a map onto i want to plot, however you pointed me in the right direction - Basemap() has an ax=... option: fig = plt.figure() grid = AxesGrid(...) for ax in grid: bm = Basemap(..., ax=ax) bm.draw... x, y = bm(lon, lat) im = ax.scatter(x, y, vmin=...) grid.cbar_axes[0].colorbar(im) this works in principle, but however i can't increase the size of the grid. even if i try something like: fig = plt.figure(1, (15,18)) fig.subplots_adjust(left=0.01, bottom=0.01, right=0.99, top=0.99) grid = AxesGrid(fig, 132, nrows_ncols = (2, 2), axes_pad = 0.1, cbar_location = top, cbar_mode=single, ) i get a small grid in the center with lots of white space around. someone knows about that? Best regards, yoshi -- RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Basemap AxesGrid
is there a way for using Basemap with AxisGrid? did someone try something like: grid = AxisGrid() for i in range(4): grid[i].scatter(with underlying Basemap) ? thank you and best regards, yoshi -- RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Basemap AxesGrid
is there a way for using Basemap with AxisGrid? did someone try something like: grid = AxisGrid() for i in range(4): grid[i].scatter(with underlying Basemap) the common thing is probably something like: fig = pl.figure() for i in range(4): fig.add_subplot(2,2,i) bm = Basemap() x, y = bm(lon, lat) pl.scatter(x, y, ..., vmin=globalmin, vmax=globalmax) that works nice, but how do i plot a global colorbar then? i think this is a common thing, i want to compare one map with different scatter plots on it ... someone did something like that before? thank you and best regards, yoshi -- RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [Basemap] savefig bbox_inches=tight
if one saves a Basemap plot with savefig option bbox_inches='tight' geographical coordinates are cut: bmap = Basemap(...) bmap.drawparallels([those,numbers,are,gone], labels=[1,0,0,0]) bmap.drawmeridians([those,numbers,are,gone], labels=[0,0,0,1]) plt.contourf(...) plt.savefig(file, bbox_inches='tight') is this missbehavior known, or is there a simple fix for that? best regards, yoshi -- The demand for IT networking professionals continues to grow, and the demand for specialized networking skills is growing even more rapidly. Take a complimentary Learning@Cisco Self-Assessment and learn about Cisco certifications, training, and career opportunities. http://p.sf.net/sfu/cisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [Basemap] savefig bbox_inches=tight
+--- Jeff Whitaker ---+ You can use the pad_inches keyword to adjust the amount of space left around the map. ... plt.savefig('bboxtight.png', bbox_inches='tight',pad_inches=0.45) yes that works fine (0.5 inches in my case). thank you. -- The demand for IT networking professionals continues to grow, and the demand for specialized networking skills is growing even more rapidly. Take a complimentary Learning@Cisco Self-Assessment and learn about Cisco certifications, training, and career opportunities. http://p.sf.net/sfu/cisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Creating a new colormap based on a cmap from matplotlib.cm?
+ Keith Hughitt -+ Hi all, Does anyone know of a good way to create a new LinearSegmentedColormap based off an existing one? I have a function which attempts to generate N optimal color map indices for a given data array. In cases where the number of values specified in _segmentdata is the same as N, then I can simply copy _segmentdata and modify the indices and create a new color map. In many cases, however, the segment data has far fewer interpolation points, e.g.: In [52]: cm.gray._segmentdata Out[52]: {'blue': ((0.0, 0, 0), (1.0, 1, 1)), 'green': ((0.0, 0, 0), (1.0, 1, 1)), 'red': ((0.0, 0, 0), (1.0, 1, 1))} Other colormaps may have an arbitrary number of interpolation points. Ideally, what I would like is a way to expand this into N points (e.g. 256) so that I use that as input for my new map. i cannot really help you with your approach, but i also think it's not so elegant to expand cmaps. did you try to understand the way cmaps can be defined by gradient borders? - http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps i.e. a friend gave me a colormap defined by points and i converted it to something like that (by just looking at the colors): ie_data = { 'red': ((0.00, 0.357, 0.357), (0.50, 1.000, 1.000), (0.75, 1.000, 1.000), (1.00, 1.000, 1.000)), 'green':((0.00, 0.467, 0.467), (0.50, 1.000, 1.000), (0.75, 0.750, 0.750), (1.00, 0.371, 0.371)), 'blue':((0.00, 0.800, 0.800), (0.50, 1.000, 1.000), (0.75, 0.157, 0.157), (1.00, 0.157, 0.157)) } ie = matplotlib.colors.LinearSegmentedColormap('ieMap', ie_data, 256) use it with cmap=ie regards -- 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-d2d-oct ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Ordering contourf within a range
you mean something like that? m.contourf(x, y, var, np.linspace(-100,100,33)) best regards -- FREE DOWNLOAD - uberSVN with Social Coding for Subversion. Subversion made easy with a complete admin console. Easy to use, easy to manage, easy to install, easy to extend. Get a Free download of the new open ALM Subversion platform now. http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [Basemap] contour plot just inside country
+- Jeff Whitaker ---+ Here's the basic idea: 1) read the germany.dat file, use it to create a _geoslib Poly instance, i.e. from mpl_toolkits.basemap import _geoslib b = np.asarray([lons,lats]).T # lons and lats are lists. germanypoly = _geoslib.Polygon(b) 2) loop over all the points on the grid and do inside = _geoslib.Point((lonpt,latpt)).within(germanypoly) filling a boolean array with the values. 3) use this boolean array as a mask to create a masked array from your data. Then, when you plot the masked array with contourf only the points inside germany will be contoured. Give this a try and let us know how it goes. -Jeff because of islands it doesn't work as expected i guess? here is what i did: bmap = Basemap(projection='aeqd', ...) x, y = bmap(lons, lats) npoints = 300 xi = np.linspace(np.amin(x), np.amax(x), npoints*.7178) yi = np.linspace(np.amin(y), np.amax(y), npoints) zi = griddata(x, y, var, xi, yi) inside = np.zeros_like(zi) lon, lat = np.loadtxt('germany-lon-lat-np.arr') bx, by = bmap(lon, lat) b = np.asarray([bx, by]).T poly = _geoslib.Polygon(b) i = 0 # i know this is slow, but ... for y in yi: for x in xi: inside.flat[i] = _geoslib.Point((x,y)).within(poly) i += 1 mzi = ma.masked_array(zi, mask=inside) here is what it looks like: http://rokuko.net/test.png matlab includes NaNs right before and after islands in the lon lat lists, is there something similar ? thank you so far, best regards PS http://rokuko.net/germany-lon-lat-np.arr -- Storage Efficiency Calculator This modeling tool is based on patent-pending intellectual property that has been used successfully in hundreds of IBM storage optimization engage- ments, worldwide. Store less, Store more with what you own, Move data to the right place. Try It Now! http://www.accelacomm.com/jaw/sfnl/114/51427378/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] 1d heat map
what are you using right now, something like that? a = np.random.random(70) x = np.empty([10,a.shape[0]]) x[:,:] = a pl.contourf(x) you might want to suppress ticks on the y-axis. best regards, yoshi -- 5 Ways to Improve Secure Unified Communications Unified Communications promises greater efficiencies for business. UC can improve internal communications as well as offer faster, more efficient ways to interact with customers and streamline customer service. Learn more! http://www.accelacomm.com/jaw/sfnl/114/51426253/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [Basemap] contour plot just inside country
+- Jeff Whitaker ---+ On 7/14/11 2:25 PM, Yoshi Rokuko wrote: hi, is it possible to restrict a contour plot to a country? if i grid my data to projection coordinates and then make a contour plot i can draw the country borders on top, but since the data plotted outside the country is a gridding artifact i would rather not plot it. Yoshi: There is no mechanism for doing this. It is possible, but you would need a way to create a mask for all the grid points outside the country of interest, and then use this mask to create a masked array to pass to contourf. -Jeff wouldn't it be possible to create such a mask using internals from Basemap.drawcountries() somehow? best regards, yoshi -- AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on Lean Startup Secrets Revealed. This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [Basemap] contour plot just inside country
hi, is it possible to restrict a contour plot to a country? if i grid my data to projection coordinates and then make a contour plot i can draw the country borders on top, but since the data plotted outside the country is a gridding artifact i would rather not plot it. to make it more clear what i mean: http://rokuko.net/basicmap.png any ideas? can one make a single country transparent? best regards, yoshi -- AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on Lean Startup Secrets Revealed. This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users