Re: [Matplotlib-users] [matplotlib-devel] License, freetype
Well, if Freetype were only distributed under the GPL, you couldn't distribute matplotlib in binary form without providing the source code. However, Freetype is distributed under more than one license. (see: https://www.freetype.org/license.html ) Because it's distributed under a BSD-style license in addition to the GPL, it can be distributed in binary form, subject to an accreditation clause: http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT In the past, I have gotten approval from corporate lawyers at a very large company to use freetype (and matplotlib) in an application that was being distributed in binary form. The dual-licensing of freetype was key in that particular case. Or that's my take on it, anyway. I'm not a Lawyer, so don't consider this legal advice in any way. Cheers! -Joe On Fri, Feb 17, 2017 at 4:52 PM, Paul Hobsonwrote: > Chad, > > My recollections is that matplotlib doesn't distribute the source code to > FreeType, it only uses it as a dependency. As such, MPL is in the clear > with its more permissive licensing. > -Paul > > On Fri, Feb 17, 2017 at 12:45 PM, CAB wrote: > >> Hi, All, >> >> I just went to install matplotlib version 2.0.0, and it has a dependency >> called "freetype". This software appears to be licensed under GPL3. My >> reading of that latter license is that, if someone wanted to distribute a >> compiled version of a program requiring matplotlib, that entire program >> would fall under the GPL3 license. I'm sure that would be a non-starter >> for many, many projects. >> >> Does anyone have any takes on this? >> >> Chad >> >> >> -- >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, SlashDot.org! http://sdm.link/slashdot >> ___ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > > > -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > ___ > Matplotlib-devel mailing list > matplotlib-de...@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > > -- Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Fwd: [matplotlib-devel] RFC: candidates for a new default colormap
On Fri, Jun 5, 2015 at 11:15 AM, Joe Kington joferking...@gmail.com wrote: Hopefully I will have some time today to play around with the D option. I want to see if I can shift the curve a bit to include more yellows and orange so that it can have a mix of cool and warm colors. I was thinking the same thing earlier. Here's my attempt: Not to jump back on topics too much, but I forgot to attach the colormap to my earlier e-mail. Here it is. from matplotlib.colors import LinearSegmentedColormap from numpy import nan, inf # Used to reconstruct the colormap in pycam02ucs.cm.viscm parameters = {'xp': [-6.1859603226509137, -14.579245694353546, -16.377806845432701, -75.430564639197684, 40.576629605406652, 14.197732722912633], 'yp': [-38.399280575539549, 5.6654676258992822, 11.061151079136692, 51.229016786570725, 35.641486810551555, -4.8261390887290077], 'min_JK': 27.8125, 'max_JK': 87.291667} cm_data = [[ 0.08488181, 0.18308161, 0.67262216], [ 0.08312345, 0.19202711, 0.66090297], [ 0.08217997, 0.20014429, 0.64976469], [ 0.08198433, 0.2075936 , 0.63911277], [ 0.08247594, 0.21447696, 0.62891889], [ 0.08359003, 0.2208603 , 0.61920504], [ 0.08524777, 0.2268386 , 0.60985788], [ 0.08738166, 0.23244191, 0.60093206], [ 0.08992038, 0.2377215 , 0.59238917], [ 0.09280155, 0.24272587, 0.58416923], [ 0.09596381, 0.24747257, 0.57631143], [ 0.0993575 , 0.251998 , 0.56876406], [ 0.10293853, 0.25632645, 0.56150762], [ 0.10666336, 0.2604716 , 0.55456023], [ 0.1105036 , 0.26445857, 0.54787429], [ 0.11443019, 0.26830128, 0.54144512], [ 0.11841518, 0.27200976, 0.53528253], [ 0.12244369, 0.27560103, 0.5293494 ], [ 0.12649882, 0.27908535, 0.52363821], [ 0.13056226, 0.28246931, 0.51815934], [ 0.13462547, 0.28576389, 0.51289008], [ 0.13868224, 0.28897881, 0.50780839], [ 0.14271871, 0.2921176 , 0.50293114], [ 0.14672864, 0.29518709, 0.49824894], [ 0.15071345, 0.29819656, 0.4937278 ], [ 0.1546626 , 0.30114819, 0.48938498], [ 0.15857184, 0.30404672, 0.48521597], [ 0.16243974, 0.30689736, 0.48120845], [ 0.16626692, 0.3097055 , 0.47734461], [ 0.17004651, 0.31247292, 0.47363702], [ 0.17377693, 0.31520325, 0.47007969], [ 0.1774579 , 0.31790023, 0.4296], [ 0.18109034, 0.32056767, 0.46337356], [ 0.18466948, 0.32320706, 0.46022069], [ 0.18819439, 0.3258211 , 0.4571996 ], [ 0.19166421, 0.32841234, 0.45430585], [ 0.19508052, 0.33098399, 0.4515254 ], [ 0.19844012, 0.33353749, 0.44886326], [ 0.20174153, 0.33607477, 0.44631801], [ 0.20498379, 0.3385979 , 0.44388601], [ 0.20816589, 0.3411088 , 0.44156374], [ 0.21128813, 0.34360991, 0.43934139], [ 0.21434794, 0.34610257, 0.43722134], [ 0.21734359, 0.34858841, 0.43520227], [ 0.22027364, 0.35106916, 0.433281 ], [ 0.22313653, 0.35354653, 0.43145439], [ 0.22593054, 0.3560222 , 0.42971931], [ 0.22865443, 0.35849817, 0.42806853], [ 0.23130553, 0.36097577, 0.42650261], [ 0.23388157, 0.36345656, 0.42501923], [ 0.23638033, 0.36594216, 0.42361498], [ 0.23879948, 0.36843418, 0.42228628], [ 0.24113658, 0.37093422, 0.42102943], [ 0.24338915, 0.37344386, 0.41984053], [ 0.24555463, 0.37596471, 0.41871526], [ 0.2476304 , 0.37849855, 0.41764727], [ 0.24961385, 0.3810466 , 0.41663458], [ 0.25150254, 0.38361032, 0.41567235], [ 0.25329409, 0.38619113, 0.41475548], [ 0.25498629, 0.38879034, 0.41387864], [ 0.25657711, 0.39140923, 0.41303625], [ 0.25806477, 0.39404893, 0.4153], [ 0.25944772, 0.3967105 , 0.41143149], [ 0.26072475, 0.39939485, 0.41065702], [ 0.26189499, 0.40210277, 0.40989287], [ 0.26295789, 0.4048349 , 0.40913271], [ 0.26391332, 0.40759175, 0.40837023], [ 0.2647615 , 0.41037366, 0.40759912], [ 0.26550293, 0.41318086, 0.40681296], [ 0.2661385 , 0.41601343, 0.40600552], [ 0.2972, 0.41887118, 0.40517133], [ 0.26709825, 0.42175387, 0.40430471], [ 0.26742604, 0.42466112, 0.40340023], [ 0.26765527, 0.42759246, 0.40245273], [ 0.26778838, 0.43054729, 0.40145736], [ 0.26782797, 0.43352494, 0.40040961], [ 0.2677768 , 0.43652465, 0.39930525], [ 0.26763777, 0.4395456 , 0.3981404 ], [ 0.26741386, 0.44258692, 0.39691145], [ 0.26710811, 0.4456477 , 0.39561511], [ 0.26672365, 0.448727 , 0.39424836], [ 0.26626363, 0.45182384, 0.39280844], [ 0.26573088, 0.45493737, 0.39129233], [ 0.26512858, 0.4580666 , 0.38969761
Re: [Matplotlib-users] [matplotlib-devel] RFC: candidates for a new default colormap
Not to plug one of my own answers to much, but here's a basic example. http://stackoverflow.com/questions/20144529/shifted-colorbar-matplotlib I've been meeting to submit a PR with a more full featured version for a few years now, but haven't. On Jun 5, 2015 4:45 PM, Sourish Basu sourish.b...@gmail.com wrote: On 06/05/2015 01:20 PM, Eric Firing wrote: Reminder: in matplotlib, color mapping is done with the combination of a colormap and a norm. This allows one to design a norm to handle the mapping, including any nonlinearity or difference between the handling of positive and negative values. This is more general than customizing a colormap; once you have a norm to suit your purpose, you can use it with any colormap. Maybe this is actually what you are already doing, but I wanted to point it out here in case some readers are not familiar with this colormap+norm strategy. Actually, I didn't use norms because I never quite figured out how to use them or how to make my own. If there's a way to create a norm with a custom mid-point, I'd love to know/use that. -Sourish Eric -- ___ Matplotlib-users mailing listMatplotlib-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-users -- *Q:* What if you strapped C4 to a boomerang? Could this be an effective weapon, or would it be as stupid as it sounds? *A:* Aerodynamics aside, I’m curious what tactical advantage you’re expecting to gain by having the high explosive fly back at you if it misses the target. -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Confused about rgb_to_hsv and hsv_to_rgb
I think you're asking how to blend a custom intensity image with an rgb image. (I'm traveling and just have my phone, so you'll have to excuse my lack of examples.) There are several ways to do this. Basically, it's analogous to blend modes in Photoshop etc. Have a look at the matplotlib.colors.LightSource.blend_overlay and blend_soft_light functions in the current github head. (And also http://matplotlib.org/devdocs/examples/specialty_plots/topographic_hillshading.html ) If you're working with 1.4.x, though, you won't have those functions. However, the math is very simple. Have a look at the code in those functions in the github head. It's basically a one liner. You'll need both the 4-band rgba image and the 1 band intensity/hillshade image to be floating point arrays scaled from 0-1. However, this is the default in matplotlib. How that helps a bit, and sorry again for the lack of examples! Joe OK, I understand. Could you suggest a way to reduce that 3D array to a 2D array and plot it with a specific colormap, while preserving the shading? I did something similar in Matlab https://mycarta.wordpress.com/2012/04/05/visualization-tips-for-geoscientists-matlab-part-ii/ But it took using some custom functions and a ton of asking and tinkering, and I'm not quite at that level with matplotlib, so any suggestion would be appreciated Thanks, Matteo On Thu, May 21, 2015 4:10 pm, Eric Firing wrote: Colormapping occurs only when you give imshow a 2-D array of numbers to be mapped; when you feed it a 3-D array of RGB values, it simply shows those colors. For colormapping to occur, it must be done on a 2-D array as a step leading up to the generation of your img_array. Eric On 2015/05/21 5:50 AM, Matteo Niccoli wrote: I posted a question on stackoverflow about creating with making my own shading effect (I want to use horizontal gradient for the shading). http://stackoverflow.com/questions/30310002/issue-creating-map-shading- in-matplotlib-imshow-by-setting-opacity-to-data-gradi Unfortunately I cannot share the data because I am using it for a manuscripts, but my notebook with full code listing and plots, here: http://nbviewer.ipython.org/urls/dl.dropbox.com/s/2pfhla9rn66lsbv/surfa ce_shading.ipynb/%3Fdl%3D0 The shading using gradient is implemented in two ways as suggested in the answer. What I do not understand is why the last plot comes out with a rainbow-like colors, when I did specify cubehelix as colormap. hsv = cl.rgb_to_hsv(img_array[:, :, :3]) hsv[:, :, 2] = tdx_n rgb = cl.hsv_to_rgb(hsv) plt.imshow(rgb[4:-3,4:-3], cmap='cubehelix') plt.show() Am I doing something wrong or is this unexpected behavior; is there a workaround? Thanks Matteo - - One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Key events using nbagg backend
Woops! You're absolutely right! I was completely confused! I mixed up the new nbagg backend with the way ipython notebooks used to display matplotlib figures. The nbagg backend is indeed interactive (and I have no idea why key press callbacks aren't supported, then). This is what happens when I reply to e-mail without putting much thought into it. Thanks! -Joe On Thu, Dec 4, 2014 at 8:58 PM, Brendan Barnwell brenb...@brenbarn.net wrote: On 2014-12-04 15:40, Joe Kington wrote: Nbagg is non-interactive, similar to Agg. No events other than draw events are supported, as far as I know. If that's the case, the release notes should probably make that clear. Right now at http://matplotlib.org/users/whats_new.html#the-nbagg-backend it says: Phil Elson added a new backend, named “nbagg”, which enables interactive figures in a live IPython notebook session. The word interactive certainly could lead people to believe that the backend is, in fact, interactive. -- Brendan Barnwell Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail. --author unknown -- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Key events using nbagg backend
Nbagg is non-interactive, similar to Agg. No events other than draw events are supported, as far as I know. I think there are long term plans to change that (eg, webagg and mplh5canvas), but it's a fairly tricky problem. How that helps clarify why things aren't working, anyway. -Joe On Dec 4, 2014 11:04 AM, reem17 el...@u.northwestern.edu wrote: I'm using matplotlib version 1.4.2 on linux and am having trouble getting key event callbacks when using the nbagg backend in an ipython notebook (i've tried in firefox and chromium). The key press events seem to not be processed (no matter what key I try to press). This code does work with the qt backend. %matplotlib nbagg import matplotlib.pyplot as plt f=plt.figure() plt.plot([1,2,3,4]) def handler(event): plt.plot([4,3,2,1]) f.canvas.mpl_connect('key_press_event',handler); Thanks for any help. -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Key-events-using-nbagg-backend-tp44551.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Matplotlib-users Digest, Vol 102, Issue 39
On Fri, Nov 21, 2014 at 10:42 AM, Pedro Marcal pedrovmar...@gmail.com wrote: @MariaLukis, I had to go through contortions to plot an arbitrary quadrilateral mesh, in 3D. I resolved it by storing every line plotted and retracing the best set to take me to the starting point of the quad I was plotting. It would have been much easier if I had the function of lifting my pen and move while not plotting. But then I did not know how to get intpo matplotlib to perform what is a simple mod. ...snip... First off, ``pcolormesh`` will happily plot arbitrary quadrilateral meshes, so long as you can describe the points in a regular manner. For example: import matplotlib.pyplot as plt import numpy as np shape = (10, 10) y, x = np.mgrid[:shape[0], :shape[1]] # Distort the grid so that it's no longer regular x = x + np.random.normal(0, 0.2, shape) y = y + np.random.normal(0, 0.2, shape) z = np.random.random(shape) fig, ax = plt.subplots() ax.pcolormesh(x, y, z) plt.show() Also, lifting the pen while not plotting is the basis of how paths are handled in matplotlib. Normally, you wouldn't drop down to this lower-level API very often, but it underpins a lot of higher-level matplotlib artists. For example, let's draw 4 squares with one path: import matplotlib.pyplot as plt from matplotlib.path import Path from matplotlib.patches import PathPatch codes = Path.LINETO * np.ones(5, dtype=np.uint8) codes[0] = Path.MOVETO x = np.array([0, 1, 1, 0, 0]) y = np.array([0, 0, 1, 1, 0]) numsquares = 4 x = np.hstack([x + 2*i for i in range(numsquares)]) y = np.hstack([y + 2*i for i in range(numsquares)]) codes = np.hstack(numsquares * [codes]) path = Path(np.c_[x, y], codes) patch = PathPatch(path, facecolor='red') fig, ax = plt.subplots() ax.add_patch(patch) ax.autoscale() ax.axis('equal') ax.margins(0.05) plt.show() Hopefully those examples help a bit (or at least give food for thought). Cheers, -Joe -- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Basemap from proj4 string
I agree that it would be useful, but basemap doesn't support EPSG codes, so this isn't fully possible in general. On a side note, if you're ever just wanting to transform coordinates, pyproj supports generic proj4 strings. (e.g. proj = pyproj.Proj(your_proj4_string)) It might be possible to initialize a projection in Cartopy from a generic pyproj projection... I'm not sure, though. At any rate, that doesn't answer your question at all, but consider it food for thought. Cheers, -Joe On Fri, Nov 7, 2014 at 7:16 AM, Knut-Frode Dagestad knutfrodesop...@hotmail.com wrote: As an example, say I have a proj4 string defining a spatial reference system: p4 = '+lon_0=0.0 +lat_ts=60.0 +R=6370997.0 +proj=stere +x_0=-0.0 +units=m +y_0=4327039.11059 +lat_0=90.0' Then one can construct a Basemap from this as: map = Basemap(projection='stere', lon_0=0., lat_0=90, lat_ts=60, llcrnrlat=50, urcrnrlat=70, llcrnrlon=0, urcrnrlon=20) I could make a function to construct Basemap arguments from any user specified proj4 string (which is out of control of my application). But that function would probably be long and contain a lot of projection-specific if-then-switches. Copying proj4 arguments directly does not work, e.g. if passing x_0=0 Basemap complains that x_0 is an unexpected argument. The problem of making a long parser is not that this is tedious, but that it is error prone and unstable e.g. with respect to future upgrades of Basemap or proj4 libraries. So as Basemap obviously does have an algorithm to create a proj4 string from its input arguments, I was hoping the reverse algorithm would also be available somehow. E.g. it would be very useful to be able to initialise a Basemap with: map = Basemap(proj4=p4, llcrnrlat=50, urcrnrlat=70, llcrnrlon=0, urcrnrlon=20) Knut-Frode -- Date: Wed, 5 Nov 2014 09:32:16 -0800 I think some examples would help. Which proj4 string are you looking to use? How are you currently constructing the map? -p On Wed, Nov 5, 2014 at 7:53 AM, knutfrode knutfrodesop...@hotmail.com wrote: Does anyone know if this is possible? -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Basemap-from-proj4-string-tp43428p44290.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Inverting a datetime / plot_date y-axis
A quick way to do this is ``ax.invert_yaxis()`` (and invert_xaxis() for the x-axis). That way you preserve auto-scaling and don't wind up with manually set axis limits. What you did should have worked, but ``ymin`` and ``ymax`` are probably datetime objects. ``ylim`` isn't smart enough to convert them to the datetime units that matplotlib uses internally. Hope that helps! -Joe On Tue, Sep 16, 2014 at 4:00 AM, Gerd Wellenreuther gerd.wellenreut...@xfel.eu wrote: Dear all, I hope some of you could help me out. I am currently trying to generate some timetables using matplotlib.pyplot.plot_date, having the time-axis on the y-axis. Typically, one would like to read these plots from top to bottom, from older to newer items (future on the bottom). Unfortunately, the default enumeration of the y-axis is the other way around, and it resists my attempts to invert its direction e.g. by changing limits using matplotlib.pyplot.ylim (Traceback below). I found a quite old entry in stackoverflow which is most probably outdated, at least the proposed solution did not work for me... ( http://stackoverflow.com/questions/5804969/displaying-an-inverted-vertical-date-axis ). Since the longish traceback seems to try to tell me I did not understand some kind of important - even trivial - point about those datetime-axis maybe some of you came about this problem before? Thanks, Gerd P.S.: Traceback after trying to use something like matplotlib.pyplot.ylim(ymax,ymin): Traceback (most recent call last): File C:\Users\gwellenr\Desktop\Test_Sabine\Plot_csv.py, line 187, in module matplotlib.pyplot.savefig(save_path+'test.png') File C:\Python27\lib\site-packages\matplotlib\pyplot.py, line 561, in savefig return fig.savefig(*args, **kwargs) File C:\Python27\lib\site-packages\matplotlib\figure.py, line 1421, in savefig self.canvas.print_figure(*args, **kwargs) File C:\Python27\lib\site-packages\matplotlib\backend_bases.py, line 2220, in print_figure **kwargs) File C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py, line 505, in print_png FigureCanvasAgg.draw(self) File C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py, line 451, in draw self.figure.draw(self.renderer) File C:\Python27\lib\site-packages\matplotlib\artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File C:\Python27\lib\site-packages\matplotlib\figure.py, line 1034, in draw func(*args) File C:\Python27\lib\site-packages\matplotlib\artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File C:\Python27\lib\site-packages\matplotlib\axes.py, line 2086, in draw a.draw(renderer) File C:\Python27\lib\site-packages\matplotlib\artist.py, line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File C:\Python27\lib\site-packages\matplotlib\axis.py, line 1091, in draw ticks_to_draw = self._update_ticks(renderer) File C:\Python27\lib\site-packages\matplotlib\axis.py, line 945, in _update_ticks tick_tups = [t for t in self.iter_ticks()] File C:\Python27\lib\site-packages\matplotlib\axis.py, line 889, in iter_ticks majorLocs = self.major.locator() File C:\Python27\lib\site-packages\matplotlib\dates.py, line 802, in __call__ self.refresh() File C:\Python27\lib\site-packages\matplotlib\dates.py, line 820, in refresh self._locator = self.get_locator(dmin, dmax) File C:\Python27\lib\site-packages\matplotlib\dates.py, line 896, in get_locator raise ValueError('No sensible date limit could be found in the ' ValueError: No sensible date limit could be found in the AutoDateLocator. -- Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce. Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce. Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Region within contour -- 2D array
Why not just use boolean indexing? E.g. to find the region that falls between 5 and 10, do (z =5) (z = 10): In [1]: import numpy as np In [2]: x, y = np.mgrid[-10:10, -10:10] In [3]: z = np.hypot(x, y) In [4]: result = (z = 5) (z = 10) In [5]: result.astype(int) Out[5]: array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]]) Cheers, -Joe On Thu, Aug 28, 2014 at 8:23 PM, Eric Firing efir...@hawaii.edu wrote: On 2014/08/28, 3:02 AM, Matthew Czesarski wrote: Hi Matplotlib Users! I have some 2-d arrays, which i am displaying with implot, and deriving contours for with contour. Easy - I'm just pulling them out of collections[0].get_paths() . However what's not easy is that I would like to recover a 1-0 or True-False array of the array values (pixels) that fall within the contours. Some line crossing algorithm/floodfill could do it, but I guess that matplotlib's fill() or contourf() must do this under the hood anyway. I've looked into the output both functions, but I don't see anything obvious.. Does anybody know if there's an a way to pull out a such an array from matplotlib? Any pointers are appreciated! Make an array of (x, y) pairs from the X and Y you use in your call to contour, and then feed that array to the contains_points() method of your contour Path. This will give you the desired Boolean array for any given Path; depending on what you want, you might need to combine arrays for more than one Path. To get closed paths, I think you will want to use contourf, not contour. Eric Cheers, Matt -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] pick_event after zooming/panning stops working.
I think the OP's desire is to have pick events fire after the zoom has been triggered. Currently, after you zoom (or pan), the zoom tool is still active until you click it again. Pick events won't fire while the zoom tool is the selected tool, and you have to manually de-select it (i.e. click the zoom button again for pick events to work). The current behavior is the right default choice, i.m.o., but it's counter-intuitive when combined with pick events. When you're building a gui to interact with data (or, for example, when using mpldatacursor -- this is a question I get a lot), a common expectation is that after you zoom once, the zoom tool is no longer active. Pick events should work again. Currently, you have to subclass (or monkey-patch) the toolbar to make this happen. It's a bit of a pain. (It's more complicated that just setting `fig.canvas.toolbar._active`.) (If I'm wrong about that, please let me know!!!) It would be nice to have an easier way to deactivate the zoom/pan tool. I think the new toolbar might have that, but I haven't checked. Cheers, -Joe On Thu, Aug 21, 2014 at 1:41 PM, Benjamin Root ben.r...@ou.edu wrote: Imagine someone creates some event that would modify an artist upon picking, or do some expensive calculation, or some other action. But, I seriously doubt anybody would want those actions to fire while using the zoom/pan tool. Especially since the mouse cursor looks totally different. I am curious why you would expect pick events to fire while using pan/zoom. What is the user-story that compels that expectation? Perhaps I could be convinced otherwise to offer some sort of toggle. On Thu, Aug 21, 2014 at 2:33 PM, Michael Kaufman kaufma...@ornl.gov wrote: What kind of bad stuff happens if we were to allow that? M On 8/21/14 2:29 PM, Benjamin Root wrote: Yes, those tools do snarf up pick events via the widgetlock mechanism, IIRC. This is entirely intentional, and I an not sure there is a bug here to fix. On Thu, Aug 21, 2014 at 12:01 PM, Thomas Caswell tcasw...@gmail.com mailto:tcasw...@gmail.com wrote: On Thu, Aug 21, 2014 at 9:44 AM, Michael Kaufman kaufma...@ornl.gov mailto:kaufma...@ornl.gov wrote: # plot axvlines here... etc. global cids # remove any previous connections for i in cids: gcf().canvas.mpl_disconnect(i) cids = [] cids.append(gcf().canvas.mpl_connect('pick_event',self.pick)) cids.append(gcf().canvas.mpl_connect('button_press_event', self.click)) draw() def pick(self, event): thisline = event.artist xdata, ydata = thisline.get_data() print xdata[0] def click(self, event): print clicked See this minimal example ``` import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.axvline(.5, picker=6) ax.plot(range(3)) cids = [] plt.draw() def pick(event): thisline = event.artist xdata, ydata = thisline.get_data() print xdata[0] def click(event): print clicked cids.append(fig.canvas.mpl_connect('pick_event', pick)) cids.append(fig.canvas.mpl_connect('button_press_event', click)) ``` If you turn the zoom/pan tool off the picker works again. I suspect that there is some logic underneath those tools that are snarfing events when the are turned on to avoid messy conflicts. There is some work going on (MEP22 iirc) to update the toolbar and make our tool handling saner. Tom -- Thomas Caswell tcasw...@gmail.com mailto:tcasw...@gmail.com -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net mailto:Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Example showing differences between Mac O$ and Windows use
That should be `matplotlib.use('TkAgg')`, not Agg. Agg is a non-interactive backend, while TkAgg is an interactive Tkinter wrapper around the Agg backend. On Thu, Mar 13, 2014 at 9:53 AM, Jeroen Hegeman jeroen.hege...@gmail.comwrote: Hi Christophe, This is (I think) a known limitation of the OS X backend. One way around this is to use another backend. Which backends are available depends on how your matplotlib was built. (And unfortunately I don't know how to figure out which ones are available, apart from trying.) In my case (matplotlib from homebrew on OS X 10.9.2) the TkAgg backend works. To use the TkAgg backend insert these two lines: import matplotlib matplotlib.use('Agg') before the line import matplotlib.pyplot as plt I hope that helps. Best regards, Jeroen On 13 Mar 2014, at 15:33, Christophe Bal projet...@gmail.com wrote: Hello, I'm a little disappointed by the following test program coming from this post. What are the technical reasons that make fail the following code under Mac O$ ? Best regards. Christophe BAL TEST --- from random import randint, choice import time import matplotlib.pyplot as plt import matplotlib.patches as mpatches back_color = black colors = ['red', 'green', 'cyan', 'yellow'] width , height = 16, 16 fig , ax = plt.subplots() ax .set(xlim=[0, width], ylim=[0, height]) # Or use ax.axis([x0,x1,y0,y1]) # Be sure to draw the canvas once before we start blitting. Otherwise # a) the renderer doesn't exist yet, and b) there's noting to blit onto fig .canvas.draw() def update(): x = randint(0, width - 1) y = randint(0, height - 1) rect = mpatches.Rectangle( (x, y), 1, 1, facecolor = choice(colors), edgecolor = back_color ) ax .add_artist(rect) start = time.time() ax .draw_artist(rect) fig .canvas.blit(ax.bbox) print(draw , time.time() - start) timer = fig.canvas.new_timer(interval=1) timer .add_callback(update) timer .start() plt .show() -- Learn Graph Databases - Download FREE O'Reilly Book Graph Databases is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Learn Graph Databases - Download FREE O'Reilly Book Graph Databases is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Learn Graph Databases - Download FREE O'Reilly Book Graph Databases is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] multiplot in a for loop
On Mar 10, 2014 1:00 PM, Gabriele Brambilla gb.gabrielebrambi...@gmail.com wrote: And how can I select in which position of the grid of plots put my errorbar plot? like axes[i].errorbar(...)? Exactly. Except that axes will be a 2d array if you have multiple rows and columns, so it would be axes[i,j].errorbar(...). If you just want to iterate over all of the subplots, use for ax in axes.flat:. Hope that helps, -Joe thanks Gabriele 2014-03-10 13:51 GMT-04:00 Paul Hobson pmhob...@gmail.com: So it sounds like you're not specifying the subplots correctly. I recommend using `fig, axes = plt.subplots(nrows=R, ncols=C)` as a replacement for `fig = plt.figure` and `fig.add_subplot()`. `axes` will be a numpy array of Axes objects through which you'll be able to loop along with your other variable. Good luck. -paul On Mon, Mar 10, 2014 at 10:46 AM, Gabriele Brambilla gb.gabrielebrambi...@gmail.com wrote: No, if you look better near the zero there are some COLOURED lines: you have this impression because the values in EcutS are enormous respect the other one in GAMMAs and Bees. When you plot them all together the other ones disappear... I don't want to plot them all together. Excuse me but it's very difficult for me to give you a self running code: it's an enormous code with a lot of things that recall each others... Thanks Gabriele 2014-03-10 12:54 GMT-04:00 Paul Hobson pmhob...@gmail.com: Gabriele, I'm confused. I only see 1 series in each subplot. Could you trim your example down into some code that we can copy, paste, and run? A more thorough description of the problem might help too. -p On Mon, Mar 10, 2014 at 9:39 AM, Gabriele Brambilla gb.gabrielebrambi...@gmail.com wrote: Hi I'm trying to do a particular plot similar to this one: http://matplotlib.org/examples/pylab_examples/line_styles.html but my code pastes different datas in the same plot. I want only one array per each plot. I attach the wrong result fdatas = plt.figure() for filename in filenames: [various things] for obsangl in angles: [various things] #fitspectrum4.fitSpec is one my personal fitting routine pa0, era0, pa1, era1, pa2, era2, pa3, era3 = fitspectrum4.fitSpec(eels, averspe, (1.0)*(10**(-8)), 0.66, 10**6, 1) GAMMAs.append(pa1) EcutS.append(pa2) Bees.append(pa3) GeR.append(era1) EeR.append(era2) beR.append(era3) ialph += 1 ialpg = ialph axum1 = fdatas.add_subplot(numalp, 3, ialpg) da1 = axum1.errorbar(angles, GAMMAs, yerr=GeR, marker = .) ialpg = ialph + 1 axum2 = fdatas.add_subplot(numalp, 3, ialpg) da2 = axum2.errorbar(angles, EcutS, yerr=EeR, marker = .) ialpg = ialph + 2 axum3 = fdatas.add_subplot(numalp, 3, ialpg) da3 = axum3.errorbar(angles, Bees, yerr=beR, marker = .) thanks Gabriele -- Learn Graph Databases - Download FREE O'Reilly Book Graph Databases is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Learn Graph Databases - Download FREE O'Reilly Book Graph Databases is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Learn Graph Databases - Download FREE O'Reilly Book Graph Databases is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] OT: Just because you can...
There's a bad meme here. Hope you'll forgive the distraction! import matplotlib.pyplot as plt import numpy as np def main(): t = np.linspace(0, 4*np.pi, 1000) fig, ax = plt.subplots() ax.plot(t, np.cos(t)) ax.plot(t, np.sin(t)) for _ in range(10): fig = inception(fig) plt.show() def fig2rgb_array(fig): fig.canvas.draw() buf = fig.canvas.tostring_rgb() ncols, nrows = fig.canvas.get_width_height() return np.fromstring(buf, dtype=np.uint8).reshape(nrows, ncols, 3) def inception(fig): fig.tight_layout() fig.set_facecolor('white') data = fig2rgb_array(fig) fig.clf() fig.add_subplot(111).imshow(data) return fig main() [image: Inline image 1] -- Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121054471iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Most generic way to wrap collections
On Tue, Jan 7, 2014 at 2:29 PM, Adam Hughes hughesada...@gmail.com wrote: Sorry, quick followup. I did find the gallery example to plot multiple patches together: http://matplotlib.org/examples/api/patch_collection.html That's excellent. Now I guess my question is how best to generalize the process of turning my objects into patches. I think I will just try to keep the geometry (ie line -- mpatch.Line) unless anyone has any better suggestions. As you've already found out, it sounds like you want a PatchCollection. There is one catch, though. Your lines/curves will need to be converted to PathPatches (which is trivial), which can then have a facecolor. Because all items in a collection will have the same facecolor by default, this means that your lines will become filled polygons, unless you specify otherwise. Therefore, you'll need to do something like this: import matplotlib.pyplot as plt from matplotlib.path import Path import matplotlib.patches as mpatches from matplotlib.collections import PatchCollection # Just a simple line, but it could be a bezier curve, etc. line = Path([(-20, -20), (-10, 10), (20, 20)]) # We'll need to convert the line to a PathPatch, and we'll throw in a circle, too line = mpatches.PathPatch(line) circle = mpatches.Circle([0, 0]) # If we don't specify facecolor='none' for the line, it will be filled! col = PatchCollection([line, circle], facecolors=['none', 'red']) fig, ax = plt.subplots() ax.add_collection(col) ax.autoscale() plt.show() Alternatively, you can just put the lines/curves in a PathCollection and the patches/polygons/etc in a PatchCollection. Hope that helps! -Joe Thanks! On Tue, Jan 7, 2014 at 3:08 PM, Adam Hughes hughesada...@gmail.comwrote: Hi, I am working on a library for image analysis which stores particles as indexed numpy arrays and provides functionality for managing the particles beyond merely image masking or altering the arrays directly. I've already designed classes for many common shapes including Lines/Curves, Circles/Ellipses, Polygons, Multi-shapes (eg 4 circles with variable overlap). What I'd really LOVE to do would be able to generate a matplotlib.Collection instance from these objects as generally as possible. Then, I'd be able to show data as a masked image, but also get a really nice looking plot from the objects in their Collection representation. So my question really is in the implementation. First, is there a general collection object that could work with ANY shape, or am I better off matching my shape to that collection? For example: line -- LineCollection *vs.*line -- GeneralCollection circle -- CircleCollection circle --- GeneralCollection And then, is the Collections plotting API flexible enough to mix all of these types together? Or would I have to settle for only being able to plot a collection of any 1 shape type at at time? I will delve into the API further, but ascertaining this information would really help me get started. Thanks -- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plotting with more than two y-axes (with twinx?)
Hi Daniel, For what it's worth, the code runs perfectly for me as-is on matplotlib 1.3.1 with python 2.7 on linux. However, based on your description, I'd guess that the second call to `twinx` is returning the same axes object. What happens when you do: print id(axes[1]), id(axes[2]) Are the id numbers the same or different? If they're the same, there may have been a regression/change that causes `twinx` to return the same object instead of creating a new axes. Cheers! -Joe On Wed, Nov 27, 2013 at 5:08 PM, dodermat dani.oderm...@gmail.com wrote: Dear all What I want to accomplish was produced two years ago in a stackoverflow snippet by Joe Kington http://stackoverflow.com/questions/7733693/matplotlib-overlay-plots-with-different-scales , and shown in the first figure below. However, when I use his snippet in matplotlib 1.3.x, I get an output where the third axis replaces the second axis, and the blue dots are accordingly distributed in only the lower half of the plot (see second figure below). I considered downdating to an older version of matplotlib, but then I came across a remark in the matplotlib FAQ http://matplotlib.org/faq/howto_faq.html#multiple-y-axis-scales . According to this remark, such a feature for twinx is on the wish list and thus not very likely to be available in an older version. Can someone please explain the Kington magic to me? http://matplotlib.1069221.n5.nabble.com/file/n42556/ksRXk.png http://matplotlib.1069221.n5.nabble.com/file/n42556/figure_1.png -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Plotting-with-more-than-two-y-axes-with-twinx-tp42556.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349351iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349351iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Is there anything pcolor can do that pcolormesh can't?
Until very recentlyhttp://stackoverflow.com/questions/20069545/2d-plotting-with-colors-like-spectrograms-magnitude-plots#comment29914445_20069545, I had somehow wound up with the impression that `pcolormesh` only handles rectilinear coordinate arrays, while `pcolor` can handle arbitrarily shaped quadrilaterals. Apparently, both pcolor and pcolormesh can handle any type of quadrilateral. For example: import numpy as np import matplotlib.pyplot as plt y, x = np.mgrid[:10, :10].astype(float) x += 0.5 * np.random.random(x.shape) y += 0.5 * np.random.random(y.shape) z = np.random.random(x.shape) fig, axes = plt.subplots(ncols=2) axes[0].pcolor(x, y, z) axes[1].pcolormesh(x, y, z) plt.show() Given that, is there any effective difference between `pcolor` and `pcolormesh` other than that `pcolor` creates a `PolyCollection` and `pcolormesh` creates a `QuadMesh`? In other words, is there anything that `pcolor` can display that `pcolormesh` can't? Thanks! -Joe -- Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. http://pubads.g.doubleclick.net/gampad/clk?id=63431311iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] indicating directions on stereographic projection.
Sourav - Are you by chance trying to make a stereonet? If so, your question makes a bit more sense. If that's what you're doing, have a look at mplstereonet. https://github.com/joferkington/mplstereonet It currently doesn't support polar stereonets, but that's something I've been meaning to add for a long time. If that's not what you're doing, then perhaps you wanted something similar to this? (The directions don't have much meaning, as others have already pointed out): from mpl_toolkits.basemap import Basemap import numpy as np import matplotlib.pyplot as plt m = Basemap(projection='npstere',boundinglat=10,lon_0=270,resolution='l') m.drawcoastlines() m.fillcontinents(color='coral',lake_color='aqua') m.drawmapboundary(fill_color='aqua') # draw parallels and meridians. m.drawparallels(np.arange(-80.,80.,20.)) ticks = m.drawmeridians(np.arange(-180.,180.,20.), labels=[True, True, True, True]) # Change the meridian label at 0 and 180 to East and West for value, label in zip([0.0, -180.0], ['East', 'West']): ticks[value][1][0].set_text(label) plt.show() Hope that helps! -Joe On Wed, Nov 6, 2013 at 1:34 PM, Jason Grout jason-s...@creativetrax.comwrote: On 11/6/13 1:10 PM, Paul Hobson wrote: I am **very far** from a GIS expert, but I believe that the cardinal directions are ambiguous at the poles. In other words, if you're standing on the North Pole, it'd difficult to head in any direction that's not towards the south pole. Curious to hear if I'm wrong, though. I'm sure I'm even farther from being a GIS expert (and probably farther from one as well :), but I think you raise an interesting point. My compass would give me directions at the geographic north pole, given that the magnetic north pole is different from the geographic north pole. I'm curious how valid it would be to use magnetic north to assign directions at the geographic north pole. My guess is not very valid, but kind of cool nonetheless. Jason -- 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 -- 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] pick event for images
Hi Nils, I'm glad you found it useful! I'm certainly not opposed to seeing it integrated into matplotlib in the long run. At the moment, though, it's probably changing a bit too quickly. There's a lot of little things I'd like to add to it. On the other hand, if it ever were integrated upstream, there's an opportunity to clean things up quite a bit, as mpldatacursor currently has quite a few workarounds for minor bugs in old versions of mpl and minor api changes, etc. Cheers! -Joe On Thu, Oct 31, 2013 at 8:00 AM, Nils Wagner nils...@googlemail.com wrote: Hi Joe, Just now I installed your package mpldatacursor and run the example image_example.py. Awesome ! Is there a chance to integrate it into matplotlib ? Nils On Wed, Oct 30, 2013 at 5:58 PM, Joe Kington joferking...@gmail.comwrote: On Oct 30, 2013 9:43 AM, Nils Wagner nils...@googlemail.com wrote: Hi all, How can I retrieve the corresponding color value in percent, when I click on the image ? You have to jump through a couple of hoops. Have a look at the _coords2index function in pick_info.py for mpldatacursor. https://github.com/joferkington/mpldatacursor/blob/master/mpldatacursor/pick_info.py Also, mpldatacursor might be useful for what you're doing. Not to plug my own project too much, but it does exactly this, among other things. Hope that helps! -Joe fig = plt.figure() ax = fig.add_subplot(111) cax = ax.imshow(col[:,::2], interpolation='nearest',extent=[0.5,20.5,0.5,2 0.5],alpha=1,picker=5) fig.canvas.mpl_connect('pick_event', onpick) def onpick(event): ... Nils -- Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] pick event for images
Hi Daniele, First off, the FSF uses and endorses a number of non GPL licenses. They reccomend the Apache license over MIT-style licenses for permissive cases due to patent issues, but they don't require it. In fact, even the GNU project has several X11 (the FSF's name for the MIT license) licensed projects (e.g. Off the top of my head, I know ncurses is both an official GNU project and is X11-licensed.). However, I'm glad you brought this up. I haven't actually filled out a copyright transfer form to the FSF. I intended to at one point, but never did and didn't think about the copyright assignment in the license header very much. Not doing so, and leaving copyright in the name of any potential contributors actually makes things quite a bit simpler. At any rate, it's certainly something I should clarify. Thanks! -Joe On Sat, Nov 2, 2013 at 11:55 AM, Daniele Nicolodi dani...@grinta.netwrote: Hello Joe, I accidentally had a look at the source file you linked to and I found the copyright and license terms quite strange. Are you really transferring copyright for your work to the Free Software Foundation which is releasing it under the MIT license? I find very strange that the FSF is using a license other than the (L)GPL. Does it also mean that who wants to contribute to your project must sign a copyright assignment to the FSF? I'm puzzled. Best, Daniele On 30/10/2013 17:58, Joe Kington wrote: On Oct 30, 2013 9:43 AM, Nils Wagner nils...@googlemail.com mailto:nils...@googlemail.com wrote: Hi all, How can I retrieve the corresponding color value in percent, when I click on the image ? You have to jump through a couple of hoops. Have a look at the _coords2index function in pick_info.py for mpldatacursor. https://github.com/joferkington/mpldatacursor/blob/master/mpldatacursor/pick_info.py Also, mpldatacursor might be useful for what you're doing. Not to plug my own project too much, but it does exactly this, among other things. Hope that helps! -Joe fig = plt.figure() ax = fig.add_subplot(111) cax = ax.imshow(col[:,::2], interpolation='nearest',extent=[0.5,20.5,0.5,2 0.5],alpha=1,picker=5) fig.canvas.mpl_connect('pick_event', onpick) def onpick(event): ... Nils -- Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net mailto:Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] pick event for images
On Oct 30, 2013 9:43 AM, Nils Wagner nils...@googlemail.com wrote: Hi all, How can I retrieve the corresponding color value in percent, when I click on the image ? You have to jump through a couple of hoops. Have a look at the _coords2index function in pick_info.py for mpldatacursor. https://github.com/joferkington/mpldatacursor/blob/master/mpldatacursor/pick_info.py Also, mpldatacursor might be useful for what you're doing. Not to plug my own project too much, but it does exactly this, among other things. Hope that helps! -Joe fig = plt.figure() ax = fig.add_subplot(111) cax = ax.imshow(col[:,::2], interpolation='nearest',extent=[0.5,20.5,0.5,2 0.5],alpha=1,picker=5) fig.canvas.mpl_connect('pick_event', onpick) def onpick(event): ... Nils -- Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Pick event after using Zoom to rectangle
If you're asking how to do it interactively, just click on the zoom button again, and you should be able to fire pick events by clicking again. Hope that helps! -Joe On Oct 29, 2013 4:58 AM, Nils Wagner nils...@googlemail.com wrote: Hi all, How can I use a pick event when I have used Zoom to rectangle before ? Nils -- Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Choosing optimal figure width/height automatically
I just realized that I replied to this off-list. Sending back out to the entire list. (Sorry for the duplicate e-mail Christoph!) On Oct 18, 2013 6:11 AM, Christoph Groth christ...@grothesque.org wrote: Joe, thank you very much for your reply. So the figsize of a matplotlib plot is the physical size of the region between the axes where the data is shown? No, your first assumption was correct. figsize refers to the size of the whole figure. What I meant to do in that example was abuse the fact that matplotlib will happily add things beyond the figure boundaries. You can then abuse the bbox_inches kwarg to savefig to show everything, while keeping the size of the data area between the axes boundaries the same as the figsize. My example there is actually completely wrong. I meant to do this: import numpy as np import matplotlib.pyplot as plt dpi = 80 data = np.random.random((100, 100)) height, width = np.array(data.shape, dtype=float) / dpi fig = plt.figure(figsize=(width, height), dpi=dpi) ax = fig.add_axes([0, 0, 1, 1]) ax.imshow(data, interpolation='none') fig.savefig('test.png', bbox_inches='tight') At any rate, I'm not quite sure if that's actually what you wanted, but it's a useful trick in cases like this. -- 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=60135031iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Choosing optimal figure width/height automatically
snip Unfortunately, figaspect is only an approximate solution, as it simply uses the aspect ration of the image for the whole figure (with axes and labels). I wonder how difficult it would be to teach matplotlib to tightly fit the axes around an image, and, ideally, output the figure cropped. So, you're wanting the image to be displayed pixel-to-pixel, but still have (tight) room for the axes, etc? If so, you can use the bbox_inches kwarg to crop out and capture the extent of the labels, etc, and just set the figure size to exactly the size of the image. For example: import numpy as np import matplotlib.pyplot as plt dpi = 80 data = np.random.random((100, 100)) height, width = np.array(data.shape, dtype=float) / dpi fig, ax = plt.subplots(figsize=(width, height), dpi=dpi) ax.imshow(data, interpolation='none') fig.savefig('test.png', bbox_inches='tight') If show the figure (i.e. plt.show()), the ticklabels, etc will be outside the figure and not shown, but they will be properly saved, regardless. Hope that helps, -Joe -- 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=60135031iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- 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=60135031iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Fwd: Python Session at AGU 2013
For anyone attending the AGU (American Geophysical Union) fall meeting this year, there will be a session on python and big data in the earth sciences. Abstract submission is still open until Aug. 6th. See below for more info. Cheers, -Joe -- Forwarded message -- From: IRIS Webmaster webmas...@iris.washington.edu Date: Thu, Aug 1, 2013 at 11:18 AM Subject: [iris-bulk] Python Session at AGU 2013 To: bulkm...@iris.washington.edu Forwarded on behalf of: Lion Krischer LMU Munich krisc...@geophysik.uni-muenchen.de Dear members of the IRIS community, with the deadline for abstract submission to the AGU Fall Meeting 2013 approaching fast, I wanted to point out a session revolving around the Python programming language. If you will be attending the meeting and are using Python for your research or workflows, please consider submitting an abstract to the IN-034 session until *next week Tuesday, August 6th*. https://fallmeeting.agu.org/2013/scientific-program/session-search/sessions/in034-ultra-scale-earth-systems-analyses-using-python/ It aims to promote the use of Python in the earth-science community. All the best, Lion Krischer and Thomas Lecocq -- Get your SQL database under version control now! Version control is standard for application code, but databases havent caught up. So what steps can you take to put your SQL databases under version control? Why should you start doing it? Read more to find out. http://pubads.g.doubleclick.net/gampad/clk?id=49501711iu=/4140/ostg.clktrk___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Linewidths in data space?
Apart from implementing this natively in matplotlib, I was thinking if I could work around this limitation for our purposes in the following way: My objects to draw will always sit in a Collection. I could derive my own Collection class with a draw() method that changes the linewidth of the collections, taking into account the current axes.transData and figure.dpi. Using that I should be able to achieve my goal, right? (given that I restrict myself to plots with the same scaling in all directions) Not to plug one of my own answers, but there's an example of using a callback to keep linewidths in data coordinates here: http://stackoverflow.com/a/15673254/325565 Have a look at the second example in the answer for the callback approach. Using something like ``shapely`` to buffer your lines as the first example does is also an option. Hope that helps a bit anyway, -Joe -- 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] Evolution of the interface
On Mar 15, 2013 10:01 AM, Christophe BAL projet...@gmail.com wrote: Hello, I really appreciate the work done by matplotlib but I really think that the interface must evolve. Here is a small example. object.set_something(...) object.get_something() It could be easier to use a jQuery like style as in the following lines. object(...) object() This will considerably simplify things. Here is a more realistic example. fig = pylab.figure() ax = fig.add_subplot(1,1,1) ax.set_xlabel(xLabel) ax.set_ylabel(yLabel) The a jQuery like style would be as in the following lines. fig = pylab.figure() ax = fig.add_subplot(1,1,1) ax(xlabel = xLabel, ylabel = yLabel) Just fyi: you can always do ax.set(xlabel=something, ylabel=something) I don't know enough matplotlib to propose other examples but I really think that there is a lot of things that could make matplotlib much more Pythonicly easy to use. Christophe BAL -- 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] Feedback on an implementation of a matlab-ish datacursor
On Wed, Mar 13, 2013 at 3:22 PM, Jonathan Slavin jsla...@cfa.harvard.eduwrote: Nevermind on my earlier question on artists and using datacursor. I figured that one out. What I did was basically (after creating the image and contours): artist = gca().images datacursor(artist) and it worked! Glad it worked! For what it's worth, you can also do: im = imshow(yourdata) datacursor(im) It's a bit cleaner than getting the AxesImage through ax.images. Cheers! -Joe Jon On Wed, 2013-03-13 at 15:50 -0400, Jonathan Slavin wrote: Joe, Thank you! I will especially use it to get the z value in images. I started to try to do something like this once but never finished. One thing I'm having a bit of trouble with is providing an artist as an argument. The reason I wanted to do that is to look only at the values for the image and not those for the contours drawn on the image. How does that work exactly? As a side note, I thought that I had found a bug because an I was looking at image would, in some places, print only the x and y values but not the z value. Then I realized it was printing the values for a contour that I had made invisible by setting its edgecolor to 'None'. This was because the contour created had two parts and I only wanted to show one of them. Anyone know a different way to do that? Regards, Jon On Tue, 2013-03-12 at 22:58 -0500, Joe Kington wrote: I recently got around to polishing up a snippet I've been using for quite awhile. https://github.com/joferkington/mpldatacursor/ and I was hoping to get some feeding on the current implementation. mpldatacursor allows a user to easily click on an artist and display a customizable, interactive pop-up box displaying information about the selected artist (e.g. x y, label, z for images and collections, etc). It's a stand-alone module (and in pypi), but you could also just download the examples directory from github and copy the mpldatacursor.py file into it to try things out. A few key questions: 1. Is this something that anyone else finds useful? 2. Does it seem intuitive? 3. Does the implementation seem flexible enough for most needs? (Note that any additional kwargs are passed on to annotate to create the data cursor, so the appearance of the box is customizable through annotation kwargs.) 4. Are there any obvious features missing? 5. Any suggestions? (especially better name suggestions...) If it is something that other people find useful, I'd be happy to submit a pull request to incorporate it into matplotlib. (If I did, it would probably be best to drop the HighlightDataCursor class, as its limited in what it can do.) Thanks a bunch! -Joe -- __ Jonathan D. Slavin Harvard-Smithsonian CfA jsla...@cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- 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
[Matplotlib-users] Feedback on an implementation of a matlab-ish datacursor
I recently got around to polishing up a snippet I've been using for quite awhile. https://github.com/joferkington/mpldatacursor/ and I was hoping to get some feeding on the current implementation. mpldatacursor allows a user to easily click on an artist and display a customizable, interactive pop-up box displaying information about the selected artist (e.g. x y, label, z for images and collections, etc). It's a stand-alone module (and in pypi), but you could also just download the examples directory from github and copy the mpldatacursor.py file into it to try things out. A few key questions: 1. Is this something that anyone else finds useful? 2. Does it seem intuitive? 3. Does the implementation seem flexible enough for most needs? (Note that any additional kwargs are passed on to annotate to create the data cursor, so the appearance of the box is customizable through annotation kwargs.) 4. Are there any obvious features missing? 5. Any suggestions? (especially better name suggestions...) If it is something that other people find useful, I'd be happy to submit a pull request to incorporate it into matplotlib. (If I did, it would probably be best to drop the HighlightDataCursor class, as its limited in what it can do.) Thanks a bunch! -Joe -- 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] Undocumented transform API change between 1.1 and 1.2?
On Mon, Dec 10, 2012 at 2:45 AM, Phil Elson pelson@gmail.com wrote: Hi Joe, Thanks for bringing this up, it is certainly valuable to highlight this on the mailinglist. As you say, the change is hard to spot and, I agree, makes library code supporting v1.1.1 and v1.2 harder than one would like. Typically, anything which is going to break core APIs (even slightly) should be documented under the API Changes page here http://matplotlib.org/api/api_changes.html#changes-in-1-2-x . Thanks! I wasn't aware of that page! (and it does a very nice job of documenting the changes!) You will find there were quite a few changes made relating to transforms which I think is entirely my doing, so at least we know who the guilty party is :-) Thanks for spotting the example failure - I split these changes over many separate pull requests and did scan the gallery for any noticeable changes, but this one must have slipped the net. If you're still having problems with using the newer transform API, please shout and I'd be happy to have a look for you. Will do, thanks for the offer! All the best, Phil On 9 December 2012 22:10, Joe Kington joferking...@gmail.com wrote: Hi folks, At some point transforms.Transform was slightly refactored. (Particularly, this commit: https://github.com/matplotlib/matplotlib/commit/8bbe2e55f29b28ba558504b27596b8e36a087c1c) This changed what methods need to be overridden when subclassing Transform. All in all, it seems like a very sensible change, but it led to some very hard-to-find bugs in some of my code that subclasses transforms.Transform. I thought I would mention it on the mailing list for anyone else that uses custom projections. Forgive me if it was mentioned earlier and I just didn't notice. With versions 1.1.x and older, one had to directly implement a transformmethod when subclassingtransforms.Transform, otherwise a NotImplemented error would be raised. With versions 1.2.x and newer, the preferred way appears to be to implement things in a separate transform_affine or transform_non_affinemethod and not explicitly implement a transform method. If you implement the non-affine portion directly in the transform method without overriding transform_non_affine, it leads to strange drawing bugs with v1.2 that did not occur with older versions. (For example, this broke one of the examples in the gallery between 1.1. and 1.2: http://matplotlib.org/1.1.1/examples/api/custom_projection_example.html http://matplotlib.org/1.2.0/examples/api/custom_projection_example.html. I just submitted a pull request to update the example, by the way.) On the other hand, for compatibility with versions 1.1 and older, you have to explicitly implement the transform method as well, otherwise you'll get the NotImplemented error. Therefore, now one needs to explicitly implement *_both_* the transform_non_affine and transform methods of a custom non-affine transform for compatibility with 1.1 and older as well as 1.2 and newer. Similarly, one needs to implement* _both_ *the transform_path_non_affineand the transform_path methods for compatibility with newer and older versions of matplotlib. Arguably, it should have always been done this way, but based onexamples/api/custom_projection_example.py, I (and I suspect many other people as well) implemented the transform directly as the transform method when subclassing Transform, instead of separately in a transform_affine or transform_non_affine method. Is this a large enough change to warrant a mention in the changelog? (On the other hand, the mailing list probably gets a lot more eyes on it than the changelog...) Thanks! -Joe -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plot with marker color coded according to z-value
That's what ``scatter`` is intended for. Basically, you want something like: plt.scatter(x, y, c=z, marker='s') plt.colorbar() Note that you can also vary the markers by size based on an additional parameter, as well. Have a look at this example: http://matplotlib.org/examples/pylab_examples/scatter_demo.html Hope that helps, -Joe On Fri, Oct 19, 2012 at 2:19 PM, elmar werling el...@net4werling.de wrote: Hi, is there a way to adjust the marker color in a xy-plot in relation to the value of a third parameter. Something as the following - not working - example 1. Example 2 is working but rather slow for large arrays. cheers Elmar # example 1 import matplotlib.pyplot as plt x = [1,2,3,4] y = x c = ((1.0, 0.0, 0.0), (0.8, 0.1, 0.1), (0.6, 0.2, 0.6), (0.4, 0.3, 0.3)) plt.plot(x,y, color=c, marker='s') plt.show() example 2: import matplotlib.pyplot as plt x = [1,2,3,4] y = x c = ((1.0, 0.0, 0.0), (0.8, 0.1, 0.1), (0.6, 0.2, 0.6), (0.4, 0.3, 0.3)) for i in range(len(x)): plt.plot(x[i], y[i], color=c[i], marker='s') plt.show() -- 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_sfd2d_oct ___ 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_sfd2d_oct___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] ANN: mplstereonet v0.2 - Stereonets for matplotlib
Announcement - mplstereonet v0.2 = mplstereonet provides lower-hemisphere equal-area and equal-angle stereonets for matplotlib. Download -- Available for download at: http://pypi.python.org/pypi/mplstereonet/0.2 See the github page for more information and development versions: https://github.com/joferkington/mplstereonet About - Stereonets are a type of plot commonly used in the geosciences for visualizing and analyzing orientation data. Orientations of linear and planar features are plotted as the intersection of the feature with a hemisphere. (Therefore, linear features plot as points and planar features plot as lines.) mplstereonet provides plotting of planes (measured as strikes and dips), poles to planes, and lineations (measured as rakes along a plane or as plunges and bearings). Additionally, mplstereonet provides orientation density contouring using a variety of standard methods (e.g. Kamb contouring, etc). Getting Started -- The easiest way to get started is to have a look at the examples: https://github.com/joferkington/mplstereonet/tree/master/examples Additionally, the readme has an overview and various examples: https://github.com/joferkington/mplstereonet/blob/master/README.rst Changes - New features in version 0.2 include: - Density contouring of orientation data using a variety of methods - Equal-angle as well as equal-area stereonets - A variety of parsing utilities - Geometric analysis utilities (e.g. plane intersections) Thank you all very much! -Joe Kington -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Newbie-question: spines with arrows
It sounds like you were using the right approach, you just got a bit lost on what some of the keyword parameters to annotate, etc do. Here's an example that should do what you want: import matplotlib.pyplot as plt from matplotlib.ticker import MultipleLocator fig, ax = plt.subplots() # Set the axis limits as you wanted... ax.set_ylim([-0.6, 1.1]) # Set major and minor tick intervals # We could just set the tick locations manually, but this way you'll keep the # same intervals when you zoom/pan/etc. ax.yaxis.set_major_locator(MultipleLocator(1)) ax.yaxis.set_minor_locator(MultipleLocator(0.1)) # Make the bottom spine float instead of being at the bottom of the plot ax.spines['bottom'].set_position(('data', 0)) # Hide the top and right spines (Similar to your sketch) for position in ['right', 'top']: ax.spines[position].set_visible(False) # Turn off the top, right, and bottom major and minor ticks (as in your sketch) ax.tick_params(which='both', top=False, right=False, bottom=False, labelbottom=False) # Draw a 15 point long arrow that will always be at the top-left corner of # the axes. The key is that we're specifying a location of (0,1) in # axes fraction coordinates. We then place an empty text string 15 _points_ # above this (the `xytext` parameter controls the amount, `textcoords` controls # how it's interpreted). Then, we draw an arrow connecting the top left corner # of the axes to the (empty and not drawn) text string. ax.annotate('', xy=(0,1), xycoords='axes fraction', xytext=(0,15), textcoords='offset points', ha='center', arrowprops=dict(arrowstyle='|-', shrinkA=0, shrinkB=0, facecolor='black')) plt.show() Hope that helps! -Joe On Fri, Jun 15, 2012 at 7:34 AM, Asbach, Mark mark.asb...@iais.fraunhofer.de wrote: Hi there, I'm sorry to ask such a newbie question, but I'd like to format a custom box plot and although there are numerous examples on the web and tons of docstrings in matplotlib, I'm stuck somehow. My problems center around axes / spines. In detail, my problems are: 1) I want an y-axis on the left that spans from -0.6 to 1.1, ends in an arrow, has major ticks at 0 and 1 and minor ticks at [0.1...0.9] As far as I understand, there is no option to let spines end in an arrow head, so I have to draw the myself. I get the ticks to appear at the right positions and the y-range to be as desired - however, the spine line is not drawn over the full y-range, but only where there is data in the diagram. Also, I copied the arrow annotation code blindly from an older post on this list, but do not understand how I can adapt the arrow head to appear at a data position (instead of at the corner of the Axes area). One problem is, that I get ticks on the right although that spine was disabled. 2) I want some kind of x-axis at y==0, without ticks and without arrow Using some methods on the spines, I can disable the top spine and move the bottom spine to zero. However, as with the y-axis, I cannot control from where to where the line itself is drawn. As attachments, you'll find a hand sketch of what my graph should look like and matplotlib code that goes nearly all the way. I would be very happy about a hint on how to fix the problems left. Thanks an advance, Mark -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Time axis for imshow
On Wed, Nov 9, 2011 at 11:45 PM, Gökhan Sever gokhanse...@gmail.com wrote: Hello, Is there any easy way to specify a time-axis using imshow to plot 2D data? Sure, just call ax.xaxis_date() (or yaxis_date, depending on which axis you want to represent a date). As a quick example: import matplotlib.pyplot as plt import matplotlib.dates as mdates import numpy as np # Generate data... ny = 100 xmin, xmax = mdates.datestr2num(['01/01/2011', '11/10/2011']) data = np.random.random((ny, int(xmax-xmin)+1)) - 0.5 data = data.cumsum(axis=1) # Plot... fig, ax = plt.subplots() ax.imshow(data, extent=[xmin, xmax, 0, ny]) ax.xaxis_date() fig.autofmt_xdate() plt.show() Cheers, -Joe -- 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] Time axis for imshow
snip Although, this doesn't give me millisecond precision. Is there any way to get ms precision via datetime module? snip Well, datetime objects, matplotlib's internal float dates, and numpy datetime64 objects all support microsecond resolution. However matplotlib's locator rules can't handle microsecond or millisecond resolution. There aren't any locators for less than second resolution. Also, imshow sets the aspect of the plot to 1 by default, which is probably why you're having to set the extents manually. If you specify aspect='auto' in the imshow call you can avoid that step. (However, strange things happen when the span of the extents drops below 100 microseconds... I'm guessing something is being cast to float32's somewhere?) As a quick example to demonstrate using sub-second resolution (without a proper tick locator): import matplotlib.pyplot as plt import numpy as np import matplotlib.dates as mdates from datetime import datetime # Generate data... ny = 100 nx = 100 xmin, xmax = mdates.date2num([datetime(2011, 01, 01, microsecond=1), datetime(2011, 01, 01, microsecond=nx)]) data = np.random.random((ny, nx)) - 0.5 data = data.cumsum(axis=1) # Plot... fig, ax = plt.subplots() ax.imshow(data, aspect='auto', extent=[xmin, xmax, 0, ny]) ax.xaxis_date() plt.show() At any rate, you can write a quick-and-dirty millisecond locator... Give me a bit and I'll cobble one together. (It's turning out to be slightly more complex than I thought...) On Thu, Nov 10, 2011 at 10:06 AM, Gökhan Sever gokhanse...@gmail.comwrote: Thanks Joe, I forgot to convert my numeric time array into a form that mpl can understand. I198 time O198 array([ 32643.78595805, 32643.82032609, 32643.85445309, ..., 32871.46535802, 32871.49946594, 32871.53384495]) I199 ncnt O199 array([0001-01-01 09:04:03+00:00, 0001-01-01 09:04:03+00:00, 0001-01-01 09:04:03+00:00, ..., 0001-01-01 09:07:51+00:00, 0001-01-01 09:07:51+00:00, 0001-01-01 09:07:51+00:00], dtype=object) Although, this doesn't give me millisecond precision. Is there any way to get ms precision via datetime module? This is not a matter for plotting, since second precision is good enough for eyes. Then setting extent properly and either calling ax.xaxis_date or calling setters manually I196 xmin = mdates.date2num(ncnt[0]) I197 xmax = mdates.date2num(ncnt[-1]) plt.imshow(z.T, interpolation='nearest', aspect='auto', origin='lower', extent=[xmin, xmax, 0, z.shape[1]]) ax = plt.gca() ax.xaxis.set_major_formatter(DateFormatter('%H:%M:%S')) ax.xaxis.set_major_locator(SecondLocator(interval=30)) ax.xaxis.set_minor_locator(SecondLocator(interval=5)) gives me better control over the major/minor ticks. On Thu, Nov 10, 2011 at 8:15 AM, Joe Kington jking...@wisc.edu wrote: On Wed, Nov 9, 2011 at 11:45 PM, Gökhan Sever gokhanse...@gmail.comwrote: Hello, Is there any easy way to specify a time-axis using imshow to plot 2D data? Sure, just call ax.xaxis_date() (or yaxis_date, depending on which axis you want to represent a date). As a quick example: import matplotlib.pyplot as plt import matplotlib.dates as mdates import numpy as np # Generate data... ny = 100 xmin, xmax = mdates.datestr2num(['01/01/2011', '11/10/2011']) data = np.random.random((ny, int(xmax-xmin)+1)) - 0.5 data = data.cumsum(axis=1) # Plot... fig, ax = plt.subplots() ax.imshow(data, extent=[xmin, xmax, 0, ny]) ax.xaxis_date() fig.autofmt_xdate() plt.show() Cheers, -Joe -- 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 -- Gökhan -- 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] Newbie question
On Wed, Nov 9, 2011 at 10:07 AM, Howard how...@renci.org wrote: Hi all I'm a new user to matplotlib, and I'm having a little difficulty with something I feel must be basic. When I plot our data, I'm using a canvas that is 4x4 at 128 DPI and saving the canvas as a png. Here's the basics of the code: imageWidth = 4 imageHeight = 4 DPI = 128 figure1 = plt.figure(figsize=(imageWidth,imageHeight)) plt.axis(off) plt.tricontourf(theTriangulation, modelData, theLookupTable.N, cmap=theLookupTable) canvas = FigureCanvasAgg(figure1) canvas.print_figure(prefix + .png, dpi=DPI) The png is 512x512 as I would expect, but the contoured image doesn't fill the whole image. How do I tell the library to map the plotted are to the entire canvas and not leave a border around the rendered image? You need to make an axis that fills up the entire figure. By default, axes don't fill up the entire figure to leave room for tick labels, axis lables, titles, etc. Try something like: import matplotlib as plt dpi = 128 fig = plt.figure(figsize=(4,4)) # Specifies an axis at 0, 0 with a width and height of 1 (the full width of the figure) ax = fig.add_axes([0,0,1,1]) ax.tricontourf(...) fig.savefig('output.png', dpi=dpi) Hope that helps, -Joe -- 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] Newbie question
On Wed, Nov 9, 2011 at 10:20 AM, Howard how...@renci.org wrote: On 11/9/11 11:13 AM, Joe Kington wrote: On Wed, Nov 9, 2011 at 10:07 AM, Howard how...@renci.org wrote: Hi all I'm a new user to matplotlib, and I'm having a little difficulty with something I feel must be basic. When I plot our data, I'm using a canvas that is 4x4 at 128 DPI and saving the canvas as a png. Here's the basics of the code: imageWidth = 4 imageHeight = 4 DPI = 128 figure1 = plt.figure(figsize=(imageWidth,imageHeight)) plt.axis(off) plt.tricontourf(theTriangulation, modelData, theLookupTable.N, cmap=theLookupTable) canvas = FigureCanvasAgg(figure1) canvas.print_figure(prefix + .png, dpi=DPI) The png is 512x512 as I would expect, but the contoured image doesn't fill the whole image. How do I tell the library to map the plotted are to the entire canvas and not leave a border around the rendered image? You need to make an axis that fills up the entire figure. By default, axes don't fill up the entire figure to leave room for tick labels, axis lables, titles, etc. Try something like: import matplotlib as plt dpi = 128 fig = plt.figure(figsize=(4,4)) # Specifies an axis at 0, 0 with a width and height of 1 (the full width of the figure) ax = fig.add_axes([0,0,1,1]) ax.tricontourf(...) fig.savefig('output.png', dpi=dpi) Hope that helps, -Joe Hi Joe That did it! Thanks much. Can I also turn off the tick marks on the new axis? Sure! If you want an exact duplicate of your original code snippet, just add an: ax.axis('off') or one of the many equivalent ways of hiding the entire axis. If you'd rather keep the outline and white background patch, but just turn the ticks off, then you can do something like: for axis in [ax.xaxis, ax.yaxis]: ax.set_ticks([]) or similarly: ax.tick_params(color='none') Also, as you've probably already noticed, I meant to have import matplotlib.pyplot as plt in my first reply, rather than import matplotlib as plt. Cheers! -- 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] Ternary Plot
The link on Nabble is broken, so here's (I think) a fixed version. It looks like the name of the branch was changed slightly at some point. https://github.com/kdavies4/matplotlib/compare/master...ternary2 Cheers, -Joe On Thu, Nov 3, 2011 at 3:14 PM, Benjamin Root ben.r...@ou.edu wrote: On Thu, Nov 3, 2011 at 2:58 PM, elmar werling el...@net4werling.dewrote: Hi, could not found anything like plot_ternary() in the matplotlib documentation. Is there an easy to use method to plot data points and lines in a ternary plot using matplotlib? Any hint is wellcome Elmar This is a requested feature, but has not been implemented yet within matplotlib. However, some other users have created a hack to do this: http://old.nabble.com/Ternary-or-triangle-plots-td32506324.html Ben Root -- 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 -- 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] how to hide axes in a 3D plot
Interestingly, things work perfectly with the latest build from guithub. Presumably the bug was fixed already? On Wed, Sep 7, 2011 at 2:40 PM, Matthew Koichi Grimes m...@cs.nyu.eduwrote: I tried Joe's code, with the call to ax.set_axis_off() moved to right after add_subplot(), as Ben suggested. The axes are still not disappearing, nor do they disappear when I interact with it (by rotating the plot). -- Matt On Wed, Sep 7, 2011 at 3:21 PM, Benjamin Root ben.r...@ou.edu wrote: On Wed, Sep 7, 2011 at 2:14 PM, Joe Kington jking...@wisc.edu wrote: This no longer seems to work with matplotlib 1.0.1. As a quick example: import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x,y,z,c = np.random.random((4,10)) ax.scatter(x, y, z, c=c) ax.set_axis_off() plt.show() The attached .png shows the result on my system... Is this a bug, or am I doing something strange? Thanks! -Joe Hmmm, try putting that call right after the add_subplot() call. I don't have time to test it out right now, but I wonder if the axes are being drawn once prior to the call to set_axis_off(). I would also be interested to know if the axes disappear when you interact with it. Ben Root -- Using storage to extend the benefits of virtualization and iSCSI Virtualization increases hardware utilization and delivers a new level of agility. Learn what those decisions are and how to modernize your storage and backup environments for virtualization. http://www.accelacomm.com/jaw/sfnl/114/51434361/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plotting in loop problem, not refreshing
Your code should work (and does on my system)... What backend, version of matplotlib, OS, etc are you running? On Sat, Jun 4, 2011 at 4:54 PM, Armin G armi...@gmail.com wrote: Hi everyone , I know this has been posted several times now, But I could not understand qietly why my simple code does not work. here is the code: http://old.nabble.com/file/p31775254/LinearConvection.pyLinearConvection.py The problem in detail: In the solver loop ( the outer loop) , The plot should be updated after every time step, but it stays the same. I'm a complete noob in python, so excuse my simple communicating language. thanks alot, Armin -- View this message in context: http://old.nabble.com/Plotting-in-loop-problem%2C-not-refreshing-tp31775254p31775254.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Discover what all the cheering's about. Get your free trial download today. http://p.sf.net/sfu/quest-dev2dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Discover what all the cheering's about. Get your free trial download today. http://p.sf.net/sfu/quest-dev2dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Getting axis limits through ax.axis() turns off autoscaling. Confusing behavior?
Thanks! -Joe On Sun, May 15, 2011 at 12:50 AM, Eric Firing efir...@hawaii.edu wrote: On 05/14/2011 12:22 PM, Joe Kington wrote: Hi, When getting an axis's extents through axis, the autoscaling state of the axis is turned off, regardless of the state it was in before calling ax.axis() E.g. import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) print ax.get_autoscale_on() limits = ax.axis() print ax.get_autoscale_on() It makes sense that it would be turned off if the axis's limits are manually set, but calling ax.get_xlim() or ax.get_ylim() doesn't change the autoscaling state, so why should getting the extents by calling ax.axis()? It is now fixed in v1.0.x and master on github. Eric This seems like confusing and/or inconsistent behavior to me. Would this be considered a bug? If not, is it worth clarifying in the docstring to axis? Thanks, -Joe -- Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Achieve unprecedented app performance and reliability What every C/C++ and Fortran developer should know. Learn how Intel has extended the reach of its next-generation tools to help boost performance applications - inlcuding clusters. http://p.sf.net/sfu/intel-dev2devmay___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Pixel shape
Actually, I think he's wanting a set aspect, right? Either way, it's just aspect=1.5 or aspect=0.6667 depending on the orientation he wants. On Mon, Apr 18, 2011 at 6:37 AM, Sebastian Berg sebast...@sipsolutions.netwrote: The solution is already the aspect='auto', ie: import numpy as np from matplotlib import pyplot as plt a = np.arange(100).reshape(10,10) plt.imshow(a, aspect='auto') aspect='auto' is what you were looking for, the documentation (as you probably already found is for example at: http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.imshow or in interactive help. On Sun, 2011-04-17 at 23:16 +0200, Paolo Zaffino wrote: Thanks for the reply. I checked in the help...I didn't understand what I must to use. Should you post me the link of the guide of this setting? Thanks! Il 16/04/2011 10:47, Sebastian Berg ha scritto: Hello, check the help ;). you can set aspect='auto' or something fixed. Regards, Sebastian On Sat, 2011-04-16 at 10:43 +0200, Paolo Zaffino wrote: Hi at all, I have a numpy matrix (an image) and I'd like to show it. I thought to use show function, but I have a question. I don't want that the pixel have dimension 1x1 unit but I want for example 1X1.5 unit (I don't want a square but a rectangle). How can I do this? Thanks in advance. Paolo -- Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Auto-wrapping text within a plot... Is there a simpler solution?
For whatever it's worth, after a lot of wrangling, I think I solved most of my problems (though perhaps not in the most efficient way). In case anyone else is looking for similar functionality, here's a callback function that will autowrap text objects to the inside of the axis they're plotted in, and should handle any font, rotation, etc that you throw at it. (The previous version had a lot of bugs). Hope someone finds it useful, at any rate... -Joe [image: E2G1j.png] import matplotlib.pyplot as plt def main(): Draw some very long strings on a figure and have the auto-wrapped to the axis boundaries. Try resizing the figure!! fig = plt.figure() plt.axis([0, 10, 0, 10]) t = This is a really long string that I'd rather have wrapped so\ that it doesn't go outside of the figure, but if it's long\ enough it will go off the top or bottom! t2 = rFurthermore, if I put mathtext in here, it won't mutilate it,\ but will treat it like a really long word. For example: \ r$\frac{\sigma}{\gamma} - e^{\theta \pm 5}$ won't be mangled! plt.text(5, 10, t2, size=14, ha='center', va='top', family='monospace') plt.text(3, 0, t, family='serif', style='italic', ha='right') plt.text(4, 1, t, ha='left', family='Times New Roman', rotation=15) plt.text(5, 3.5, t, ha='right', rotation=-15) plt.title(This is a really long title that I want to have wrapped so\ r it does not go outside the axis boundaries, ha='center') # All we do to autowrap everything is connect a callback function... fig.canvas.mpl_connect('draw_event', on_draw) plt.show() def on_draw(event): Auto-wraps all text objects in a figure at draw-time import matplotlib as mpl fig = event.canvas.figure # Cycle through all artists in all the axes in the figure for ax in fig.axes: for artist in ax.get_children(): # If it's a text artist, wrap it... if isinstance(artist, mpl.text.Text): autowrap_text(artist, event.renderer) # Temporarily disconnect any callbacks to the draw event... # (To avoid recursion) func_handles = fig.canvas.callbacks.callbacks[event.name] fig.canvas.callbacks.callbacks[event.name] = {} # Re-draw the figure.. fig.canvas.draw() # Reset the draw event callbacks fig.canvas.callbacks.callbacks[event.name] = func_handles def autowrap_text(textobj, renderer): Wraps the given matplotlib text object so that it doesn't exceed the boundaries of the axis it is plotted in. # Get the starting position of the text in pixels... x0, y0 = textobj.get_transform().transform(textobj.get_position()) # Get the extents of the current axis in pixels... clip = textobj.get_axes().get_window_extent() # Set the text to rotate about the left edge (nonsensical otherwise) textobj.set_rotation_mode('anchor') # Get the amount of space in the direction of rotation to the left and # right of x0, y0 (left and right are relative to the rotation) rotation = textobj.get_rotation() right_space = min_dist_inside((x0, y0), rotation, clip) left_space = min_dist_inside((x0, y0), rotation - 180, clip) # Use either the left or right distance depending on the h-alignment. alignment = textobj.get_horizontalalignment() if alignment is 'left': new_width = right_space elif alignment is 'right': new_width = left_space else: new_width = 2 * min(left_space, right_space) # Convert to characters with a minimum width of 1 character wrap_width = max(1, new_width // pixels_per_char(textobj)) try: wrapped_text = safewrap(textobj.get_text(), wrap_width) except TypeError: # This appears to be a single word wrapped_text = textobj.get_text() textobj.set_text(wrapped_text) def min_dist_inside(point, rotation, box): Gets the space in a given direction from point to the boundaries of box (where box is an object with x0, y0, x1, y1 attributes, point is a tuple of x,y, and rotation is the angle in degrees) from math import sin, cos, radians x0, y0 = point rotation = radians(rotation) distances = [] threshold = 0.0001 if cos(rotation) threshold: # Intersects the right axis distances.append((box.x1 - x0) / cos(rotation)) if cos(rotation) -threshold: # Intersects the left axis distances.append((box.x0 - x0) / cos(rotation)) if sin(rotation) threshold: # Intersects the top axis distances.append((box.y1 - y0) / sin(rotation)) if sin(rotation) -threshold: # Intersects the bottom axis distances.append((box.y0 - y0) / sin(rotation)) return min(distances) def pixels_per_char(textobj): Determines the average width of a character of the given textobj by drawing a test string and calculating it's length test_text = 'Try something like a test'
[Matplotlib-users] Auto-wrapping text within a plot... Is there a simpler solution?
Hi folks, First off, I apologize for the wall of text... Spurred on by this Stack Overflow questionhttp://stackoverflow.com/questions/4018860/text-box-in-matplotlib/4056853#4056853, and by an itch I've been wanting to scratch lately, I put together a a callback function that (attempts, anyway) to auto-wrap text artists to the boundaries of the axis they're in. It is often useful to have text reflow/auto-wrap within the axis boundaries during interactive use (resizing a plot with lots of labeled points, for example...). It doesn't really need to be precise, as long as it keeps words from being fully off the figure. A full gui toolkit would be a better way of handling this, but I've gotten in the habit of slapping a few callback functions onto matplotlib figures to make (simple) interactive scripts that I can share across platforms. (Lab exercises, in my case.) Having a way to make text reflow within the axis boundaries during resizing of plots makes things a bit easier. I'm aware that this isn't really possible in a general, backend-independent fashion due to the subtleties of text rendering in matplotlib (e.g. things like latex, where the length of the raw string has nothing to do with it's rendered size, and the general fact that the size of the text isn't known until after it's drawn).Even getting it approximately correct is still useful, though. I have it working about as well as the approach I'm taking can do, I think, but I could use some help on a couple of points. I have two specific questions, and one more general one... First: Is it possible to disconnect and then reconnect a callback function from an event within the callback function, and without disconnecting all other callback functions from the event? I'm redrawing the canvas within a draw_event callback function, and I'm currently avoiding recursion by disconnecting and reconnecting all callbacks to the draw event. It would be nice to disconnect only the function I'm inside, but I can't find any way of getting its cid... Alternatively, is there a way to redraw a figure's canvas without triggering a draw event? Second: Is there any way to determine the average aspect ratio of a font in matplotlib? I'm trying to approximate the length of a rendered text string based on it's font size and the number of characters. Currently, I'm assuming that all fonts have an average aspect ratio of 0.5, which works decently for most non-monospaced fonts, but fails miserably with others. Finally: Is there a better way to do this? My current approach has tons of limitations but works in most situations. My biggest problem so far is that vertical alignment in matplotlib (quite reasonably) refers to an axis-aligned bounding box, rather than within a text aligned bounding box. This makes reflowing rotated text more difficult, and I'm only half-way dealing with rotated text in the code below. Any suggestions on any points are welcome! Thanks! -Joe import matplotlib.pyplot as plt def main(): fig = plt.figure() plt.plot(range(10)) t = This is a really long string that I'd rather have wrapped so that it\ doesn't go outside of the figure, but if it's long enough it will go\ off the top or bottom! plt.text(7, 3, t, ha='center', rotation=30, va='center') plt.text(5, 7, t, fontsize=18, ha='center') plt.text(3, 0, t, family='serif', style='italic', ha='right') plt.title(This is a really long title that I want to have wrapped so it\ does not go outside the figure boundaries) fig.canvas.mpl_connect('draw_event', on_draw) plt.show() def on_draw(event): import matplotlib as mpl fig = event.canvas.figure # Cycle through all artists in all the axes in the figure for ax in fig.axes: for artist in ax.get_children(): # If it's a text artist, wrap it... if isinstance(artist, mpl.text.Text): autowrap_text(artist, event.renderer) # Temporarily disconnect any callbacks to the draw event... # (To avoid recursion) func_handles = fig.canvas.callbacks.callbacks[event.name] fig.canvas.callbacks.callbacks[event.name] = {} # Re-draw the figure.. fig.canvas.draw() # Reset the draw event callbacks fig.canvas.callbacks.callbacks[event.name] = func_handles def autowrap_text(textobj, renderer): import textwrap from math import sin, cos # Get the starting position of the text in pixels... x0, y0 = textobj.get_transform().transform(textobj.get_position()) # Get the extents of the current axis in pixels... clip = textobj.get_axes().get_window_extent() # Get the amount of space in the direction of rotation to the left and # right of x0, y0 # (This doesn't try to correct for different vertical alignments, and will # have issues with rotated text when va ha are not 'center') dx1, dx2 = x0 - clip.x0, clip.x1 - x0 dy1, dy2 = y0 - clip.y0, clip.y1 - y0 rotation =
Re: [Matplotlib-users] How to find out the extend of the actual image in pixels
If you're just looking for the dimensions of the overall figure in pixels, you can easily access them through other means. E.g: import matplotlib.pyplot as plt fig = plt.figure() _, _, width, height = fig.bbox.extents # - Extent of the figure in pixels fig.savefig('temp.png', dpi=fig.dpi) # - Be sure to specify the dpi!! Note that you'll have to specify that you want to save the figure at the same DPI it was when you called the extents... The figure will be saved with whatever default DPI is in your .matplotlibrc, which is commonly different than the default screen dpi (80). Hope that helps, -Joe On Wed, Sep 29, 2010 at 9:44 AM, Alexander Dietz alexanderdie...@googlemail.com wrote: Hi, On Wed, Sep 29, 2010 at 16:00, John Hunter jdh2...@gmail.com wrote: On Wed, Sep 29, 2010 at 8:50 AM, Alexander Dietz alexander.diet...@googlemail.com wrote: print ax.transData.transform((10.0, 20.0)) [ 576. 432.] Why do you say it's wrong? Note that in mpl, (0,0) is (bottom left), not (upper,left). So this is saying that the yellow dot at 10,20 (data coords) is 576 pixels up from the bottom and 432 pixels over from the left. ok maybe it is. But then I need the size of the entire figure written to a file. How can I find out the pixel-size of the entire figure, inclusive every title, axis, labels... Thanks Alex JDH -- Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] sector colouring?
Have a look at fill_between: http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.fill_between Basically, You'd want something like this: import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, np.pi, 20) y = np.sin(x) plt.figure() plt.fill_between(x, y, where=y0, facecolor='blue', interpolate=True) plt.fill_between(x, y, where=y0, facecolor='yellow', interpolate=True) plt.show() Hope that helps! -Joe On Mon, Sep 27, 2010 at 8:10 AM, Piter_ x.pi...@gmail.com wrote: Hi all. Is it possiblle in matplotlib to draw something like this? http://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/Integral_example.svg/420px-Integral_example.svg.png Thanks. Petro. -- Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Adding a Legend
On Sun, Sep 19, 2010 at 10:40 PM, Kelson Zawack zawack...@gis.a-star.edu.sg wrote: Is there a way to put the legend for a graph inside the margin instead of on the graph, in other words to put the legend where excel would? Look into either figlegendhttp://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.figlegend or the bbox_to_anchor keyword argument to legend. You can use either of these to place the legend outside of the axis boundaries. However, this won't resize the original axes. Sometimes, it's easier to just make a new, separate axis for the legend, and resize the original axis. This is easily done with the axes_grid toolkit. E.g.: import matplotlib.pyplot as plt from matplotlib import cm import numpy as np from mpl_toolkits.axes_grid1 import make_axes_locatable # Make some data data = np.random.random(10) x = np.arange(data.size) colors = cm.jet(x.astype(np.float) / x.size) names = [repr(i) for i in range(data.size)] # Basic bar plot fig = plt.figure() ax = fig.add_subplot(111) bars = ax.bar(x, data, color=colors) # Now make a new axis for the legend that takes up 10% of the width... divider = make_axes_locatable(ax) legend_ax = divider.append_axes('right', '10%') legend_ax.axis('off') # Now make the legend on the new axis legend_ax.legend(bars, names, mode='expand', frameon=False) plt.show() Hope that helps! -Joe -- Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Setting y-tick locations on an image plot changes y-axis limits, Bug or expected behavior?
Thanks for the amazingly quick turnaround! -Joe On Sat, Aug 21, 2010 at 1:34 PM, Eric Firing efir...@hawaii.edu wrote: On 08/20/2010 12:18 PM, Joe Kington wrote: Hi, I've recently noticed that setting the y-tick locations on an image plot changes the y-axis limits, while changing the x-tick locations does not change the x-axis limits. I wouldn't have expected either to change the axis limits, but it seems quite inconsistent that the y-axis and x-axis behave differently in this situation. The axis limits are easily restored by a call to ax.axis('image'), but this seems unnecessary. A very quick search of the bug tracker doesn't reveal anything matching this description... Is this expected behavior or a bug? As an example, setting the y-tick locations changes the y-axis limits: import numpy as np import matplotlib.pyplot as plt num = 10 data = np.arange(num**2).reshape((num,num)) fig = plt.figure() ax = fig.add_subplot(111) cax = ax.imshow(data) ax.set_yticks(range(num//2)) fig.show() However, setting the x-tick locations does not change the axis limits... import numpy as np import matplotlib.pyplot as plt num = 10 data = np.arange(num**2).reshape((num,num)) fig = plt.figure() ax = fig.add_subplot(111) cax = ax.imshow(data) ax.set_xticks(range(num//2)) fig.show() As a reference, I'm running matplotlib 1.0.0 with python 2.7.0 on a 64-bit Linux (kernel 2.6.31) machine. I can confirm this on python 2.6 and matplotlib 0.99 as well, though. If this isn't expected behavior, I'll be glad to open a bug report. Joe, Thanks for the report. The fix is in svn 8652 and 8653. Eric Thanks! -Joe -- This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Setting y-tick locations on an image plot changes y-axis limits, Bug or expected behavior?
Hi, I've recently noticed that setting the y-tick locations on an image plot changes the y-axis limits, while changing the x-tick locations does not change the x-axis limits. I wouldn't have expected either to change the axis limits, but it seems quite inconsistent that the y-axis and x-axis behave differently in this situation. The axis limits are easily restored by a call to ax.axis('image'), but this seems unnecessary. A very quick search of the bug tracker doesn't reveal anything matching this description... Is this expected behavior or a bug? As an example, setting the y-tick locations changes the y-axis limits: import numpy as np import matplotlib.pyplot as plt num = 10 data = np.arange(num**2).reshape((num,num)) fig = plt.figure() ax = fig.add_subplot(111) cax = ax.imshow(data) ax.set_yticks(range(num//2)) fig.show() However, setting the x-tick locations does not change the axis limits... import numpy as np import matplotlib.pyplot as plt num = 10 data = np.arange(num**2).reshape((num,num)) fig = plt.figure() ax = fig.add_subplot(111) cax = ax.imshow(data) ax.set_xticks(range(num//2)) fig.show() As a reference, I'm running matplotlib 1.0.0 with python 2.7.0 on a 64-bit Linux (kernel 2.6.31) machine. I can confirm this on python 2.6 and matplotlib 0.99 as well, though. If this isn't expected behavior, I'll be glad to open a bug report. Thanks! -Joe -- This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Fit a plane to a set of xyz points
On Tue, Jul 27, 2010 at 1:37 PM, Friedrich Romstedt friedrichromst...@gmail.com wrote: 2010/7/26 Mathew Yeates mat.yea...@gmail.com: Is there a simple function call for this? And finding the distance of a point to the plane? Hmm, when you are interested in the z distance alone, it should be a matrix equation: Z = X * m_x + Y * m_y + 1 * n Meaning you can invert it with Moore-Penrose pseudoinversion, i.e., numpy.lstsq()? When you have weights on Z, normalise first. Friedrich Just one quick note on this: If you fit Z = aX + bY + c, you won't be able to resolve vertical planes. Likewise, if you fit x = aY + Bz + c or y = aX + bZ + c you won't be able to resolve horizontal planes. If you need to robustly fit a plane to a point cloud, you'll need to try all three formulations. See here for a quick example of what Friedrich mentioned using all three formulations and choosing the most robust result: http://code.google.com/p/python-geoprobe/source/browse/geoprobe/common.py#198 As far as finding the distance of a given point (x0, y0, z0) to the plane defined by 0 = ax + by + cz + d, the equation is just abs(a * x0 + b * y0 + c * z0 + d) / sqrt(a**2 + b**2 + c**2). See herehttp://mathworld.wolfram.com/Point-PlaneDistance.html for a more detailed explanation. -Joe -- The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://ad.doubleclick.net/clk;226879339;13503038;l? http://clk.atdmt.com/CRS/go/247765532/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Smooth contourplots
It sounds like you're wanting a gaussian kernel density estimate (KDE) (not the desktop!). The other options you mentioned are for interpolation, and are not at all what you're wanting to do. You can use scipy.stats.kde.gaussian_kde()http://www.scipy.org/doc/api_docs/SciPy.stats.kde.gaussian_kde.html. However, it currently doesn't take a weights array, so you'll need to modify it for your use case. If you prefer, I have faster version of a gaussian KDE that can take a weights array. It's actually slower than the scipy's gaussian kde for a low number of points, but for hundreds, thousands, or millions of points, it's several orders of magnitude faster. (Though the speedup depends on the covariance of the points... higher covariance = slower, generally speaking) Here's a quick pastebin of the code. http://pastebin.com/LNdYCZgw To use it, you do something like the below... (assuming the code in the pastebin is saved in a file called fast_kde.py) import numpy as np import matplotlib.pyplot as plt from fast_kde import fast_kde # From your description of your data... weights, x, y = np.loadtxt('chain.txt', usecols=(0,4,6)).T kde_grid = fast_kde(x, y, gridsize=(200,200), weights=weights) # Plot the grid plt.figure() plt.imshow(kde_grid, extent=(x.min(), x.max(), y.max(), y.min()) # Reverse the y-axis plt.gca().invert_yaxis() plt.show() Hope that helps a bit, -Joe On Sat, Jul 24, 2010 at 3:56 AM, montefra franz.berges...@googlemail.comwrote: Hi, I am writing a program that reads three columns (one column containing the weights, the other two containing the values I want to plot) from a file containing the results from a MonteCarlo Markov Chain. The file contains thousends of lines. Then create the 2D histogram and make contourplots. Here is a sample of the code (I don't know if is correct, it's just to show what I do) import numpy as np import matplotlib.pyplot as mplp chain = np.loadtxt(chain.txt, usecols=[0,4,6]) #read columns 0 (the weights), 4 and 6 (the data), from the file chain.txt h2D, xe, ye = np.histogram2D(chain[:,1],chain[:,2], weights=chain[:,0]) #create the 2D histogram x = (xe[:-1] + xe[1:])/2. #x and y values for the plot (I use the mean of each bin) y = (ye[:-1] + ye[1:])/2. mplp.figure() #open the figure mplp.contourf(x, y, h2D.T, origin='lower') #contour plot As it is the contours are not smooth and they look not that nice. After days of searches I've found three methods and tried, unsuccesfully, to apply them 1) 2d interpolation: I got segmentation fault (on a quadcore machine with 8Gb of RAM) 2) Rbf (radial basis functions): I got wrong contours 3) ndimage: it creates spurious features (like secondary peaks parallel to the direction of the main one) Before beginning with Python, I used to use IDL to plot, and there is a function 'smooth' that smooth for you 2D histograms. I haven't found anything similar for Python. Does anyone have an idea or suggestion on how to do it? Thank in advance Francesco -- View this message in context: http://old.nabble.com/Smooth-contourplots-tp29253884p29253884.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://ad.doubleclick.net/clk;226879339;13503038;l? http://clk.atdmt.com/CRS/go/247765532/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://ad.doubleclick.net/clk;226879339;13503038;l? http://clk.atdmt.com/CRS/go/247765532/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] extract country borders data convert to shapefile
If you just need the GSHHS data in shapefile format, it's available on the NOAA GSHHS website http://www.ngdc.noaa.gov/mgg/shorelines/gshhs.html. If you prefer a direct link [96MB zip file]: http://www.ngdc.noaa.gov/mgg/shorelines/data/gshhs/version2.0/shapefiles/gshhs_shp_2.0.zip Hope that helps, -Joe On Wed, Jun 30, 2010 at 6:34 PM, P. R.M. romero...@hotmail.com wrote: I have a non-matplotlib related project that requires usage of GSHHS dataset shapefiles. The regular GSHHS dataset doesnt appear to include political boundaries, however the GSHHS dataset used by matplotlib/basemap does include country/border data. I'd like to extract matplotlib/basemap GSHHS country data convert it to shapefile format. specifically, the following files that are included with matplotlib/basemap: countries_c.dat countries_f.dat countries_h.dat countries_i.dat countries_l.dat countriesmeta_c.dat countriesmeta_f.dat countriesmeta_h.dat countriesmeta_i.dat countriesmeta_l.dat how can I convert these files to shapefile format, or where can I get shapefiles that already include this data that are based on the GSHHS coastline data? please help, thanks, P.Romero -- The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail. Get busy.http://www.windowslive.com/campaign/thenewbusy?tile=multiaccountocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4 -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] extract country borders data convert to shapefile
Ah, sorry I misunderstood. You can get them by using GMT's gshhs tool (or just using pscoast with the right options) to dump out the political borders in GMT format and then convert them to a shapefile using ogr2org (or whichever tool you find easiest... Personally I use the python wrappers around ogr for more control.) To save you a bit of trouble, I zipped political boundary shapefiles (from GSHHS version 2.0, so they'll coincide perfectly with the GSHHS coastline data) and put them here: http://www.geology.wisc.edu/~jkington/borders.ziphttp://www.geology.wisc.edu/%7Ejkington/borders.zip There's probably a way to do it using basemap, as well, but I don't know it off the top of my head. Hope that helps, -Joe On Wed, Jun 30, 2010 at 9:33 PM, P. R.M. romero...@hotmail.com wrote: hi, thanks for the response. I already have know how to use the GSHHS coastline data; what I need is political boundaries (country borders) data that will coincide with the GSHHS coastline data. In other words, I can't simply use any political boundaries shapefile, since the coastlines will not line up with the various resolutions of the GSHHS coastline data. I hope this makes it a little more clear... So, I'd like to source the country border data from matplotlib/basemap's GSHHS dataset, and convert it to shapefile format. can anyone please provide some guidance on how to achieve this? thanks again, P.Romero -- Date: Wed, 30 Jun 2010 19:43:34 -0500 From: jking...@wisc.edu Subject: Re: [Matplotlib-users] extract country borders data convert to shapefile To: romero...@hotmail.com CC: matplotlib-users@lists.sourceforge.net If you just need the GSHHS data in shapefile format, it's available on the NOAA GSHHS website http://www.ngdc.noaa.gov/mgg/shorelines/gshhs.html. If you prefer a direct link [96MB zip file]: http://www.ngdc.noaa.gov/mgg/shorelines/data/gshhs/version2.0/shapefiles/gshhs_shp_2.0.zip Hope that helps, -Joe On Wed, Jun 30, 2010 at 6:34 PM, P. R.M. romero...@hotmail.com wrote: I have a non-matplotlib related project that requires usage of GSHHS dataset shapefiles. The regular GSHHS dataset doesnt appear to include political boundaries, however the GSHHS dataset used by matplotlib/basemap does include country/border data. I'd like to extract matplotlib/basemap GSHHS country data convert it to shapefile format. specifically, the following files that are included with matplotlib/basemap: countries_c.dat countries_f.dat countries_h.dat countries_i.dat countries_l.dat countriesmeta_c.dat countriesmeta_f.dat countriesmeta_h.dat countriesmeta_i.dat countriesmeta_l.dat how can I convert these files to shapefile format, or where can I get shapefiles that already include this data that are based on the GSHHS coastline data? please help, thanks, P.Romero -- The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail. Get busy.http://www.windowslive.com/campaign/thenewbusy?tile=multiaccountocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4 -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. See how.http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2 -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Reverse y-axis?
There's no single function to do it, but just reversing the current ylimits manually is a one-liner. (plt is matplotlib.pyplot, here) plt.ylim(plt.ylim()[::-1]) Hope that helps, -Joe On Fri, Jun 25, 2010 at 6:41 AM, Preben Randhol rand...@pvv.org wrote: Hi I need to plot some data vs depth. In stead of giving depths as 0,-1000,-2000, I want to give the depths as 0,1000,2000 but when plotting the data goes downwards (as if they had been negative). Can I get the y-axis to reverse so it goes downwards and not upwards? -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib and large array
One workaround is to try converting it to a PIL image first. For whatever reason, imshow chokes on large arrays, but handles PIL images of the same array just fine. However, you'll need to set the colormap and such through PIL, which can be a bit frustrating if you're unfamiliar with it. Also, you'll quite likely need to rescale your data if it's a float. Hope that points you in the right direction, anyway -Joe On Wed, Jun 9, 2010 at 1:31 PM, Massimo Di Stefano massimodisa...@gmail.com wrote: Hi All, i need to work with a relative large images 60 mb (single band geotiff file) i store it in python as a numpy array using python-gdal, the array dinension is (7173 X 7924) single band image, but tring to display it with matshow/imageshow or other matplotlib functions i have that python freeze itself and is not able to load the image. if i use a subset of the image, i 'm able to display it or at least i hade to reduce its resolution using hacks like : reduced_array = array[::3,::3] i don't need full resolution dataset when the image is displaied with a full zoom out so the reduction reduced_array = array[::3,::3] is good to show the complete image but when i zoom in the image i obviously lost data (less resolution) what do you use to display large dataset ? i'm thinking about a piramid with multy array based on the different zoom levels .. but maybe this idea is not so cool. someone already has developed similar code ? thanks to All for any suggestion! Regards, Massimo -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plotting a vector in matplotlib
Isn't that what quiverhttp://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.quiverdoes? Or am I misunderstanding the question? 2010/5/3 aditya bhargava bluemangrou...@gmail.com Thanks Johan and Matthias, I was just wondering if there was a built-in way to do this in matplotlib. It seems like it would be a useful method to have. Adit 2010/5/3 Johan Grönqvist johan.gronqv...@gmail.com 2010-05-02 20:19, aditya bhargava skrev: Is there a straightforward way of plotting a vector in matplotlib? Suppose I want to plot the vector [1 2]'. If I pass this vector in to plot(), I get the line that passes through (0,1), (1,2). Instead I want the line that passes through (0,0),(1,2). I use pyplot.Arrow to visualize displacement fields. This is a snippet copied from the code I use (it sits in a loop over all vectors I want to plot): arr = plt.Arrow(x, y, dx, dy) plt.gca().add_patch(arr) In your case, you would have (x, y) = (0, 0) and (dx, dy) = (1, 2). Regards Johan -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- wefoundland.com -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users