[Matplotlib-users] Colormap norm (vmin, vmax) based on visible part of figure
Hi all, I'm wondering if anyone knows how to compute colorbar limits (vmin, vmax) based only on the visible portion of the figure. My use-case is a pcolormesh(x, y, z) drawn over a Basemap instance. The coordinates x and y cover the entire globe, but I'm only mapping the Arctic. What happens is that the normalization is done over the entire z array, while only a subset of z actually appears on the map. The colors appearing on the map thus cover only a small fraction of the entire color range. From what I managed to understand, pcolormesh creates a collections of patches colorcoded based on the array attribute. So my question is if there is a builtin way to know which items of this collections are clipped so I can mask this part of the array ? Thanks a lot, David -- 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] Fetching a data slab with NetCDFFile
Arthur, I wrote the date2index function and I think what you are seeing is a bug that I fixed a couple of months ago. By using the latest version of netcdf4-python, not only should this bug disappear, but you'll also find that date2index now supports different selection methods: 'exact', 'before', 'after', 'nearest', that should help with your use case. If this does not fix the problem you are seeing, I'd appreciate having a copy of the file and code to reproduce the problem and find a solution. HTH, David Huard On Mon, Sep 7, 2009 at 9:27 AM, Arthur M. Greene a...@iri.columbia.eduwrote: Hi All, The problem is not with fetching the data slice itself, but finding the correct indices to specify, particularly with the time dimension. The below examples refer to a remote dataset that I can open and slice using indices, as in slice = remoteobj.variables['tas'][:120,20:40,30:50]. However, I have problems when trying to use the syntax in plotsst.py or pnganim.py (from the examples) to find time indices: In [107]: from datetime import datetime as dt In [108]: date0 = dt(1951,1,1,0) In [110]: print date0 1951-01-01 00:00:00 In [125]: timedata = remoteobj.variables['time'] In [126]: nt0 = date2index(date0,timedata) --- AssertionErrorTraceback (most recent call last) /home/amg/work/nhmm/ipython console in module() /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/__init__.pyc in date2index(dates, nctime, calendar) 3924 Returns an index or a sequence of indices. 3925 - 3926 return netcdftime.date2index(dates, nctime, calendar=None) 3927 3928 def maskoceans(lonsin,latsin,datain,inlands=False): /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc in date2index(dates, nctime, calendar) 986 987 # Perform check again. -- 988 _check_index(index, dates, nctime, calendar) 989 990 # convert numpy scalars or single element arrays to python ints. /usr/local/cdat/trunk/lib/python2.5/site-packages/mpl_toolkits/basemap/netcdftime.pyc in _check_index(indices, dates, nctime, calendar) 941 for n,i in enumerate(indices): 942 t[n] = nctime[i] -- 943 assert numpy.all( num2date(t, nctime.units, calendar) == dates) 944 945 AssertionError: - It turns out that date0 corresponds best to index 1080: In [139]: remoteobj.variables['time'][1080] Out[139]: 32865.5 In [141]: num2date(32865.5,timedata.units,timedata.calendar) Out[141]: 1951-01-16 12:00:00 This isn't the _exact_ date and time I had specified, but In [142]: date0 = dt(1951,01,16,12,00,00) In [143]: print date0 1951-01-16 12:00:00 In [144]: date2index(date0,timedata,timedata.calendar) produces the same AssertionError. Where is the problem? What I would _like_ to do is to issue a simple call using coordinates rather than the indices, of the form: slice = variable[date0:date1,[plev],lat0:lat1,lon0:lon1], or similar, preferably without writing a whole module just to find the correct indices. I need to fetch similar slices from a group of models, having time axes that may each be defined slightly differently -- different calendars, time point set at a different day of the month, etc. (It's monthly data and I'm specifying only monthly bounds, even though the calendar may be defined as days since 1860...) I need to automate the process so I get back the correct slab regardless. Suggestions appreciated! Thx, Arthur *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~* Arthur M. Greene, Ph.D. The International Research Institute for Climate and Society (IRI) The Earth Institute, Columbia University, Lamont Campus amg at iri dot columbia dot edu | http://iri.columbia.edu *^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~*^*~* -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july___ Matplotlib-users
Re: [Matplotlib-users] xticklabels printed twice when using twinx
I'd also be interested in a workaround. I tried to remove the tick labels from the second axe, but it also removed the labels from the first axe. Thanks, David On Sun, Feb 8, 2009 at 9:14 AM, Christoffer Aberg christoffer.ab...@fkem1.lu.se wrote: Hi all, I have noticed a funny behaviour when using twinx to do two plots on the same axes: the xticklabels are printed twice, once for each axes. This shows up as slightly thicker labels than for a single axes. It is particularly visible for ps or pdf output, but can be seen also in an interactive session. I can also see this in the figure shown for the two_scales.py example (http://matplotlib.sourceforge.net/_images/two_scales.png), where the xticklabels are thicker than the yticklabels (though it is not so apparent due to different colours. I therefore assume it is not just my installation. (Adding for tl in ax2.get_xticklabels(): tl.set_fontsize(16) just before the last plt.show() in two_scales.py makes it even more visible) Does anyone know of a reasonable work-around? Surely it is not the intended behaviour? Thanks for any help, Christoffer Åberg -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today- http://p.sf.net/sfu/adobe-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] preventing extra whitespace around figure
Have you tried pdfcrop ? It computes margin automatically, you could then transfer the file back to eps. David PDFCROP 1.5, 2004/06/24 - Copyright (c) 2002, 2004 by Heiko Oberdiek. Syntax: pdfcrop [options] input[.pdf] [output file] Function: Margins are calculated and removed for each page in the file. Options:(defaults:) --help print usage --(no)verbose verbose printing (false) --(no)debug debug informations(false) --gscmd name call of ghostscript (gs) --pdftexcmd name call of pdfTeX(pdftex) --margins left top right bottom (0 0 0 0) add extra margins, unit is bp. If only one number is given, then it is used for all margins, in the case of two numbers they are also used for right and bottom. --(no)clip clipping support, if margins are set (false) --(no)hires using `%%HiResBoundingBox'(false) instead of `%%BoundingBox' --papersize foo parameter for gs's -sPAPERSIZE=foo, use only with older gs versions 7.32 () Examples: pdfcrop --margins 10 input.pdf output.pdf pdfcrop --margins '5 10 5 20' --clip input.pdf output.pdf 2008/2/29, Alan G Isaac [EMAIL PROTECTED]: On Fri, 29 Feb 2008, Michael Hearne apparently wrote: I gave this a shot, and eps2eps seems not to have any effect on the bounding box. I've done some experiments where I reduce the bounding box by hand, which works really well - the only problem is I need a way to determine where the edge of my plot really is. Hmmm. That is just what eps2eps should do. Perhaps there is something drawn outside what you believe your picture is? Here are more possibilities: http://www.physics.ohio-state.edu/cgi-bin/fom?_recurse=1file=103#file_105 Some Python code to exploit this GS ability is here: http://citadel.tistory.com/130 Cheers, Alan Isaac - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bug or problem in my configuration
I'd like to thank all those who participated in fixing this bug. It's much appreciated. David 2007/10/29, John Hunter [EMAIL PROTECTED]: On 10/29/07, Michael Droettboom [EMAIL PROTECTED] wrote: I submitted a fix for this in matplotlib SVN r4047. Freetype takes a FT_LOAD_FORCE_AUTOHINT flag to force it to bypass the patented bytecode hinter at runtime (even if it was compiled in). This appears to fix the problem, and doesn't force people to recompile their freetype -- they should now get identical results regardless. Andrew Straw and I taught a workshop at the Claremont Colleges this weekend and I was running mpl from svn. When I brought up the 1st figure in ipython -pylab mode running GTKAgg, the fonts were totally whacked (see attached) and I was reminded of why they call it the bleeding edge. Fortunately, it only affected the first draw of an ipython session. For example, a figure resize, which triggers the draw, made the problem go away, and subsequent figures were fine. Odd. I just updated from svn and it looks like the problem is gone on that machine, so I hope this was the source of the problem (the workshop machine was running open-suse) In [2]: !uname -a Linux ns3 2.6.18.8-0.5-bigsmp #1 SMP Fri Jun 22 12:17:53 UTC 2007 i686 i686 i386 GNU/Linux In other news, TkAgg is segfaulting in that environment, but I haven't had time to track it down since I was busy preparing the course material. JDH - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now http://get.splunk.com/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib - representation of nan values in 2D
Hi Dirk, If you haven't already done so, look at the numpy.ma module. It provides a masked array object that deals gracefully with missing values. To the best of my knowledge, most matplotlib functions understand masked arrays and deal with it accordingly, exception made of those requiring a full matrix (such as contour). Take a look at examples/image_masked.py. Also, in the Basemap toolkit, there is at least one example showing how to plot a masked array on a map. Cheers, David 2007/9/26, Dirk Zickermann [EMAIL PROTECTED]: Dear matplotlib group, for the represenation of 2d measurement data I use the contourplot function from matplotlib. Some points in this map are not measurabel, therefore I get a non numerical value (nan) output. From this data I want to generate a map and a histogram plot. This works fine, as long as I use regular matrix/array data structure without any voids. My questions are: (1) How can I make use of plotting data with NAN values as contour and asigns such values eg as black points? (2) How can I use the matplotlib hist() function with this data, that also include such missing data points? Maybe there is an easy workaround for this. Thanks a lot for your support, Dirk (python2.51 /matplotlib-0.90.1, win32) my code: ... import matplotlib ... my2dData=[[1,2,3,4,5.0 ,NaN,7,8,9,10],[10,9,8,7,6,5,4,3,2,1]] ... figure(1) imshow(my2dData) pylab.show() .. - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Subplot order
Salut Nicolas, You can get by with something like: a = arange(nrow*ncol)+1 indices = hstack(a.reshape(nrow, ncol).T) for i in indices: subplot(nrow, ncol, i) ... David 2007/1/15, Nicolas Bigaouette [EMAIL PROTECTED]: Hi, I want to compare data and I am doing so with subplots. Ideally, I would like the subplot command to fill the columns before filling the rows as it is doing right now. Now: subpot(221) = 1st row, 1st column subpot(222) = 1st row, 2nd column subpot(223) = 2nd row, 1st column subpot(224) = 2nd row, 2nd column I'd like : subpot(221) = 1st row, 1st column subpot(222) = 2nd row, 1st column subpot(223) = 1st row, 2nd column subpot(224) = 2nd row, 2nd column Anyone knows if this is possible? Thank you. - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Controling the tick thickness
François, These options can be found in the matplotlibrc configuration figure, or can be set at runtime using the rc command. David2006/10/5, François Beaubert [EMAIL PROTECTED]: Hi all,I have look in the doc and examples but was unable to find a way to controlthe thickness of the major and minor tick on the axis.Forgive me for this very basic question but if you now a way to do that... Thanks a lotFrancois--François BEAUBERTENSIAME/LMEBureau A9Université de Valenciennes - Le Mont Houy - 59313 Valenciennes Cedex 9Téléphone: (0/33)3 27 51 19 72Télécopie: (0/33)3 27 51 19 61 Mel: [EMAIL PROTECTED]--This message has been scanned for viruses anddangerous content by MailScanner, and isbelieved to be clean. -Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cashhttp://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___Matplotlib-users mailing listMatplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Controling the tick thickness
configuration file... sorry 2006/10/5, François Beaubert [EMAIL PROTECTED]: Hi all,I have look in the doc and examples but was unable to find a way to controlthe thickness of the major and minor tick on the axis.Forgive me for this very basic question but if you now a way to do that... Thanks a lotFrancois--François BEAUBERTENSIAME/LMEBureau A9Université de Valenciennes - Le Mont Houy - 59313 Valenciennes Cedex 9Téléphone: (0/33)3 27 51 19 72Télécopie: (0/33)3 27 51 19 61 Mel: [EMAIL PROTECTED]--This message has been scanned for viruses anddangerous content by MailScanner, and isbelieved to be clean. -Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cashhttp://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___Matplotlib-users mailing listMatplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Stacked subplots
Hi,To remove the ticklabels, you could do it with something like[ax.xaxis.set_ticklabels([]) for ax in f.axes[:-1]]David2006/9/14, Jose Gomez-Dans [EMAIL PROTECTED]:Hi!I am coding a little application that shows a number of subplots (of the 511, 512...515 type) stacked up. They all have the same x-axis,and I want them to only have the xticks labels on the downward mostaxes. The subplots are defined in a matplotlib.figure.Figure object,and have been created using the add_subplot() method. I am unsure on how to go about squeezing the plots vertically (although thesubplots_adjust method seems to solve this), and how to get rid of theaxis.Ideally, I would also like to have a legend OUTSIDE the subplots. Is this possible given that the Figure is inserted in a wxFrame?I'm a newbie when it comes to both MPL and wxWindows, so sorry if thissounds very vague. I'm happy to provide more information, only thatI'm not sure of what! :D Cheers for your time,Jose-Using Tomcat but need to do more? Need to support web services, security?Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimohttp://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___Matplotlib-users mailing listMatplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Default dpi for savefig
Hi, I'm a little bit lost with respect to setting the resolution of images saved in png.The matplotlibrc file sets the dpi to 80, but the default keyword argument of savefig is set to 150. Thus, changing the rc setting to dpi=300 does not modify savefig's default behaviour. Is there a way to set a default dpi that would be used when calling savefig ?Thanks, David - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] vertical alignment of text
Hi all, Is there a way to align text vertically so that the characters sit on a continuous line ? When I dotext(.5, .5, 'abc', verticalalignment='center')text(.6, .5, 'pqr', verticalalignment='center') both words are not aligned since the bars of p and q push the text upwards. I get similar problems with 'top' and 'bottom' alignment.Thanks, David - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users