You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
(12) |
Sep
(12) |
Oct
(56) |
Nov
(65) |
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(59) |
Feb
(78) |
Mar
(153) |
Apr
(205) |
May
(184) |
Jun
(123) |
Jul
(171) |
Aug
(156) |
Sep
(190) |
Oct
(120) |
Nov
(154) |
Dec
(223) |
2005 |
Jan
(184) |
Feb
(267) |
Mar
(214) |
Apr
(286) |
May
(320) |
Jun
(299) |
Jul
(348) |
Aug
(283) |
Sep
(355) |
Oct
(293) |
Nov
(232) |
Dec
(203) |
2006 |
Jan
(352) |
Feb
(358) |
Mar
(403) |
Apr
(313) |
May
(165) |
Jun
(281) |
Jul
(316) |
Aug
(228) |
Sep
(279) |
Oct
(243) |
Nov
(315) |
Dec
(345) |
2007 |
Jan
(260) |
Feb
(323) |
Mar
(340) |
Apr
(319) |
May
(290) |
Jun
(296) |
Jul
(221) |
Aug
(292) |
Sep
(242) |
Oct
(248) |
Nov
(242) |
Dec
(332) |
2008 |
Jan
(312) |
Feb
(359) |
Mar
(454) |
Apr
(287) |
May
(340) |
Jun
(450) |
Jul
(403) |
Aug
(324) |
Sep
(349) |
Oct
(385) |
Nov
(363) |
Dec
(437) |
2009 |
Jan
(500) |
Feb
(301) |
Mar
(409) |
Apr
(486) |
May
(545) |
Jun
(391) |
Jul
(518) |
Aug
(497) |
Sep
(492) |
Oct
(429) |
Nov
(357) |
Dec
(310) |
2010 |
Jan
(371) |
Feb
(657) |
Mar
(519) |
Apr
(432) |
May
(312) |
Jun
(416) |
Jul
(477) |
Aug
(386) |
Sep
(419) |
Oct
(435) |
Nov
(320) |
Dec
(202) |
2011 |
Jan
(321) |
Feb
(413) |
Mar
(299) |
Apr
(215) |
May
(284) |
Jun
(203) |
Jul
(207) |
Aug
(314) |
Sep
(321) |
Oct
(259) |
Nov
(347) |
Dec
(209) |
2012 |
Jan
(322) |
Feb
(414) |
Mar
(377) |
Apr
(179) |
May
(173) |
Jun
(234) |
Jul
(295) |
Aug
(239) |
Sep
(276) |
Oct
(355) |
Nov
(144) |
Dec
(108) |
2013 |
Jan
(170) |
Feb
(89) |
Mar
(204) |
Apr
(133) |
May
(142) |
Jun
(89) |
Jul
(160) |
Aug
(180) |
Sep
(69) |
Oct
(136) |
Nov
(83) |
Dec
(32) |
2014 |
Jan
(71) |
Feb
(90) |
Mar
(161) |
Apr
(117) |
May
(78) |
Jun
(94) |
Jul
(60) |
Aug
(83) |
Sep
(102) |
Oct
(132) |
Nov
(154) |
Dec
(96) |
2015 |
Jan
(45) |
Feb
(138) |
Mar
(176) |
Apr
(132) |
May
(119) |
Jun
(124) |
Jul
(77) |
Aug
(31) |
Sep
(34) |
Oct
(22) |
Nov
(23) |
Dec
(9) |
2016 |
Jan
(26) |
Feb
(17) |
Mar
(10) |
Apr
(8) |
May
(4) |
Jun
(8) |
Jul
(6) |
Aug
(5) |
Sep
(9) |
Oct
(4) |
Nov
|
Dec
|
2017 |
Jan
(5) |
Feb
(7) |
Mar
(1) |
Apr
(5) |
May
|
Jun
(3) |
Jul
(6) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
|
1
(1) |
2
|
3
(10) |
4
(17) |
5
(7) |
6
(21) |
7
(15) |
8
(6) |
9
(7) |
10
(8) |
11
(6) |
12
(11) |
13
(11) |
14
(13) |
15
(4) |
16
(5) |
17
(8) |
18
(8) |
19
(15) |
20
(3) |
21
(10) |
22
(5) |
23
(7) |
24
(8) |
25
(29) |
26
(26) |
27
(7) |
28
(2) |
29
(3) |
30
(3) |
|
|
|
|
|
|
Ack, OK, to answer my own question... Somehow ipython was caching the definition of jmkfigure, so changing the module in the jmkfigure.py file did not actually change the version ipython was using. Running a new version of ipython, it worked fine. Sorry for the chatter, and thanks for the pointers.. Cheers, Jody On Sep 8, 2012, at 6:18 AM, Jody Klymak <jk...@uv...> wrote: > Hi all, > > Thats what I thought too: > > I have: jmkfigure.py: > > =============== > from pylab import * > > def jmkfigure(): > rc('figure',figsize=(3+3/8,8.5/2),dpi=96) > rc('font',size=9); > =========== > > and test.py: > > ========= > from pylab import * > > from jmkfigure import * > > jmkfigure() > figure(1) > plot([1,2,3]); > > show() > ============== > > >>> run test.py > > yields a traceback ending w/: > > =========== > Users/jklymak/teaching/Phy411/project/jmkfigure.py in jmkfigure() > 1 from pylab import * > ----> 2 > 3 def jmkfigure(): > 4 rc('figure',figsize=(3+3/8,8.5/2),dpi=96) > 5 rc('font',size=9); > > NameError: global name 'rc' is not defined > ======== > > Same error if I just import "rc" from matplot lib.... > > Is it some strange set up problem? If I put the same def in test.py it works fine... > > Thanks, Jody > > On Sep 7, 2012, at 22:52 PM, Paul Tremblay <pau...@gm...> wrote: > >> in your jmkfile.py you should have >> >> from pylab import * >> >> Paul >> >> >> On 9/8/12 12:45 AM, Jody Klymak wrote: >>> Hi All, >>> >>> Sorry to ask a dumb python newbie question, but the problem arose while reading the matplotlib documentation, and an hour or so on the internet didnt' help, so I felt it was fair-ish game to post here. >>> >>> In http://matplotlib.sourceforge.net/examples/pylab_examples/customize_rc.html it says: >>> """ >>> If you like to work interactively, and need to create different sets >>> of defaults for figures (eg one set of defaults for publication, one >>> set for interactive exploration), you may want to define some >>> functions in a custom module that set the defaults, eg >>> >>> def set_pub(): >>> rc('font', weight='bold') # bold fonts are easier to see >>> >>> Then as you are working interactively, you just need to do >>> >>>>>> set_pub() >>> """ >>> >>> Which I thought was great, because I'd like to have some presets for different journals. However, saving the def into a file (jmkfigure.py) and calling >>> >>> from jmkfigure import * >>> >>> set_pub() >>> >>> yields the error: "NameError: global name 'rc' is not defined" >>> >>> I tried importing matplotlib and rc into jmkfigure.py, but to no avail. >>> >>> I appreciate this is a scoping issue with python, but I can't figure out how to set rc from within an external module. >>> >>> Thanks for any help, >>> >>> Cheers, Jody >>> >>> >>> >>> >>> >>> >> >> ------------------------------------------------------------------------------ >> 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 >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- > Jody Klymak > http://web.uvic.ca/~jklymak/ > > > > > ------------------------------------------------------------------------------ > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Jody Klymak http://web.uvic.ca/~jklymak/
Hi all, Thats what I thought too: I have: jmkfigure.py: =============== from pylab import * def jmkfigure(): rc('figure',figsize=(3+3/8,8.5/2),dpi=96) rc('font',size=9); =========== and test.py: ========= from pylab import * from jmkfigure import * jmkfigure() figure(1) plot([1,2,3]); show() ============== >>> run test.py yields a traceback ending w/: =========== Users/jklymak/teaching/Phy411/project/jmkfigure.py in jmkfigure() 1 from pylab import * ----> 2 3 def jmkfigure(): 4 rc('figure',figsize=(3+3/8,8.5/2),dpi=96) 5 rc('font',size=9); NameError: global name 'rc' is not defined ======== Same error if I just import "rc" from matplot lib.... Is it some strange set up problem? If I put the same def in test.py it works fine... Thanks, Jody On Sep 7, 2012, at 22:52 PM, Paul Tremblay <pau...@gm...> wrote: > in your jmkfile.py you should have > > from pylab import * > > Paul > > > On 9/8/12 12:45 AM, Jody Klymak wrote: >> Hi All, >> >> Sorry to ask a dumb python newbie question, but the problem arose while reading the matplotlib documentation, and an hour or so on the internet didnt' help, so I felt it was fair-ish game to post here. >> >> In http://matplotlib.sourceforge.net/examples/pylab_examples/customize_rc.html it says: >> """ >> If you like to work interactively, and need to create different sets >> of defaults for figures (eg one set of defaults for publication, one >> set for interactive exploration), you may want to define some >> functions in a custom module that set the defaults, eg >> >> def set_pub(): >> rc('font', weight='bold') # bold fonts are easier to see >> >> Then as you are working interactively, you just need to do >> >>>>> set_pub() >> """ >> >> Which I thought was great, because I'd like to have some presets for different journals. However, saving the def into a file (jmkfigure.py) and calling >> >> from jmkfigure import * >> >> set_pub() >> >> yields the error: "NameError: global name 'rc' is not defined" >> >> I tried importing matplotlib and rc into jmkfigure.py, but to no avail. >> >> I appreciate this is a scoping issue with python, but I can't figure out how to set rc from within an external module. >> >> Thanks for any help, >> >> Cheers, Jody >> >> >> >> >> >> > > ------------------------------------------------------------------------------ > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Jody Klymak http://web.uvic.ca/~jklymak/
On 2012年09月07日 7:52 PM, Paul Tremblay wrote: > in your jmkfile.py you should have > > from pylab import * Or to be more pythonic, import only what you actually need in a given module, e.g., from matplotlib import rc Eric > > Paul > > > > On 9/8/12 12:45 AM, Jody Klymak wrote: >> Hi All, >> >> Sorry to ask a dumb python newbie question, but the problem arose while reading the matplotlib documentation, and an hour or so on the internet didnt' help, so I felt it was fair-ish game to post here. >> >> Inhttp://matplotlib.sourceforge.net/examples/pylab_examples/customize_rc.html it says: >> """ >> If you like to work interactively, and need to create different sets >> of defaults for figures (eg one set of defaults for publication, one >> set for interactive exploration), you may want to define some >> functions in a custom module that set the defaults, eg >> >> def set_pub(): >> rc('font', weight='bold') # bold fonts are easier to see >> >> Then as you are working interactively, you just need to do >> >>>>> set_pub() >> """ >> >> Which I thought was great, because I'd like to have some presets for different journals. However, saving the def into a file (jmkfigure.py) and calling >> >> from jmkfigure import * >> >> set_pub() >> >> yields the error: "NameError: global name 'rc' is not defined" >> >> I tried importing matplotlib and rc into jmkfigure.py, but to no avail. >> >> I appreciate this is a scoping issue with python, but I can't figure out how to set rc from within an external module. >> >> Thanks for any help, >> >> Cheers, Jody >> >> >> >> >> >> > > > > ------------------------------------------------------------------------------ > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
in your jmkfile.py you should have from pylab import * Paul On 9/8/12 12:45 AM, Jody Klymak wrote: > Hi All, > > Sorry to ask a dumb python newbie question, but the problem arose while reading the matplotlib documentation, and an hour or so on the internet didnt' help, so I felt it was fair-ish game to post here. > > In http://matplotlib.sourceforge.net/examples/pylab_examples/customize_rc.html it says: > """ > If you like to work interactively, and need to create different sets > of defaults for figures (eg one set of defaults for publication, one > set for interactive exploration), you may want to define some > functions in a custom module that set the defaults, eg > > def set_pub(): > rc('font', weight='bold') # bold fonts are easier to see > > Then as you are working interactively, you just need to do > >>>> set_pub() > """ > > Which I thought was great, because I'd like to have some presets for different journals. However, saving the def into a file (jmkfigure.py) and calling > > from jmkfigure import * > > set_pub() > > yields the error: "NameError: global name 'rc' is not defined" > > I tried importing matplotlib and rc into jmkfigure.py, but to no avail. > > I appreciate this is a scoping issue with python, but I can't figure out how to set rc from within an external module. > > Thanks for any help, > > Cheers, Jody > > > > > >
Hi All, Sorry to ask a dumb python newbie question, but the problem arose while reading the matplotlib documentation, and an hour or so on the internet didnt' help, so I felt it was fair-ish game to post here. In http://matplotlib.sourceforge.net/examples/pylab_examples/customize_rc.html it says: """ If you like to work interactively, and need to create different sets of defaults for figures (eg one set of defaults for publication, one set for interactive exploration), you may want to define some functions in a custom module that set the defaults, eg def set_pub(): rc('font', weight='bold') # bold fonts are easier to see Then as you are working interactively, you just need to do >>> set_pub() """ Which I thought was great, because I'd like to have some presets for different journals. However, saving the def into a file (jmkfigure.py) and calling from jmkfigure import * set_pub() yields the error: "NameError: global name 'rc' is not defined" I tried importing matplotlib and rc into jmkfigure.py, but to no avail. I appreciate this is a scoping issue with python, but I can't figure out how to set rc from within an external module. Thanks for any help, Cheers, Jody
Thanks Ben, that solved my issue. I guess I got thrown off because the plot stayed open, as you described. It's hard to troubleshoot when you don't get any errors. In the future I will attach all of my objects. -Mark On Fri, Sep 7, 2012 at 12:03 PM, Benjamin Root <ben...@ou...> wrote: > I think I see your problem... see below: > > > class start_lasso(): > def __init__(self): > data = [Datum(*xy) for xy in rand(100, 2)] > > fig = figure() > ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), > autoscale_on=False) > lman = LassoManager(ax, data) > show() > > You aren't saving any of the objects created in the "start_lasso" class to > your start_lasso object. Luckily, with the way pyplot works, the figure > object your create gets implicitly saved to the "pyplot state manager" (a > sort of smart global location for the figure objects), and the axes object > gets implicitly attached to the figure object. Therefore, when the python > execution goes out of this scope, the figure object and the axes do not get > garbage-collected. However, the lasso widget that gets created and all the > callbacks that were attached are all done with weak references to the figure > and axes. So when you leave this scope, the LassoManager no longer exists > and the callback fails to execute (as designed). > > So, make sure that at least lman (and possibly fig and ax) gets saved to the > start_lasso object to solve that part of the problem. Next, you don't save > the start_lasso object your create anywhere, so even if you saved lman to > start_lasso, the start_lasso object gets garbage-collected anyway as a > temporary. > > I hope this is clear. Let me know if you still have more issues. > > Cheers! > Ben Root >
I think I see your problem... see below: class start_lasso(): def __init__(self): data = [Datum(*xy) for xy in rand(100, 2)] fig = figure() ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) lman = LassoManager(ax, data) show() You aren't saving any of the objects created in the "start_lasso" class to your start_lasso object. Luckily, with the way pyplot works, the figure object your create gets implicitly saved to the "pyplot state manager" (a sort of smart global location for the figure objects), and the axes object gets implicitly attached to the figure object. Therefore, when the python execution goes out of this scope, the figure object and the axes do not get garbage-collected. However, the lasso widget that gets created and all the callbacks that were attached are all done with weak references to the figure and axes. So when you leave this scope, the LassoManager no longer exists and the callback fails to execute (as designed). So, make sure that at least lman (and possibly fig and ax) gets saved to the start_lasso object to solve that part of the problem. Next, you don't save the start_lasso object your create anywhere, so even if you saved lman to start_lasso, the start_lasso object gets garbage-collected anyway as a temporary. I hope this is clear. Let me know if you still have more issues. Cheers! Ben Root
On Sep 7, 2012, at 11:04 AM, Eric Firing wrote: > On 2012年09月07日 4:00 AM, Benjamin Root wrote: >> >> >> On Fri, Sep 7, 2012 at 9:49 AM, Shahar Shani-Kadmiel >> <ka...@po... <mailto:ka...@po...>> wrote: >> >> On Sep 7, 2012, at 4:25 PM, Benjamin Root wrote: >> >>> >>> >>> On Fri, Sep 7, 2012 at 8:44 AM, Shahar Shani-Kadmiel >>> <ka...@po... <mailto:ka...@po...>> wrote: >>> > <snip> > Normalization has to handle all sorts of inputs--masked or not, all > sorts of numbers, scalar or array--and it is much easier to do this > efficiently if all these possibilities are reduced to a very few at the > start. Specifically, it needs to supply a copy of the input (so that > normalization doesn't change the original) in a floating point masked > array, using float32 if possible for space efficiency. It needs to keep > track of whether the input was a scalar, so that normalization can > return a scalar when given a scalar input. > > Eric Another option as I understand it is to pass in a 1D (greyscale) or 3d (color) array (where the 3rd dimension is RGB and optionally A) of type uint8(?). This array does not need to get normalized, it will be displayed as raw pixel values. I don't remember if you also have to specifically tell it not to normalize the data. But the easier answer for your case would probably be imshow(data[::10,::10]) which will take every 10th element in x and y thus reducing the size by a factor of 100 (depending on the size of your data you could use ::2 or ::50, etc) Ethan
On 2012年09月07日 4:00 AM, Benjamin Root wrote: > > > On Fri, Sep 7, 2012 at 9:49 AM, Shahar Shani-Kadmiel > <ka...@po... <mailto:ka...@po...>> wrote: > > On Sep 7, 2012, at 4:25 PM, Benjamin Root wrote: > >> >> >> On Fri, Sep 7, 2012 at 8:44 AM, Shahar Shani-Kadmiel >> <ka...@po... <mailto:ka...@po...>> wrote: >> >> 1. an ipython session is invoked with qtconsole --pylab >> 2. I load a large NetCDF grid (Grid file format: nf (# 18) GMT >> netCDF format (float) (COARDS-compliant) [DEFAULT]), approx. >> 1.15 GB >> 3. I then try to plot with imshow the data >> >> added below are the lines leading up to the error and the >> error itself. >> >> >> This is running on OS X 10.7.4 with a recently installed EPD 7.3. >> >> >> {code} >> from scipy.io <http://scipy.io/> import netcdf_file as netcdf >> data = >> netcdf('srtm_43_44_05_06_07_08.grd','r').variables['z'][::-1] >> >> fig, ax = subplots() >> >> data.shape >> Out[5]: (24004, 12002) >> >> im = ax.imshow(data, >> aspect=((data.shape[1])/float(data.shape[0])), >> interpolation='none') >> --------------------------------------------------------------------------- >> MemoryError Traceback (most >> recent call last) >> <ipython-input-6-f92e4c4c63b5> in <module>() >> ----> 1 im = ax.imshow(data, >> aspect=((data.shape[1])/float(data.shape[0])), >> interpolation='none') >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py >> in imshow(self, X, cmap, norm, aspect, interpolation, alpha, >> vmin, vmax, origin, extent, shape, filternorm, filterrad, >> imlim, resample, url, **kwargs) >> 6743 im.set_clim(vmin, vmax) >> 6744 else: >> -> 6745 im.autoscale_None() >> 6746 im.set_url(url) >> 6747 >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py >> in autoscale_None(self) >> 281 if self._A is None: >> 282 raise TypeError('You must first set_array >> for mappable') >> --> 283 self.norm.autoscale_None(self._A) >> 284 self.changed() >> 285 >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py >> in autoscale_None(self, A) >> 889 ' autoscale only None-valued vmin or vmax' >> 890 if self.vmin is None: >> --> 891 self.vmin = ma.min(A) >> 892 if self.vmax is None: >> 893 self.vmax = ma.max(A) >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc >> in min(obj, axis, out, fill_value) >> 5873 def min(obj, axis=None, out=None, fill_value=None): >> 5874 try: >> -> 5875 return obj.min(axis=axis, >> fill_value=fill_value, out=out) >> 5876 except (AttributeError, TypeError): >> 5877 # If obj doesn't have a max method, >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc >> in min(self, axis, out, fill_value) >> 5054 # No explicit output >> 5055 if out is None: >> -> 5056 result = >> self.filled(fill_value).min(axis=axis, out=out).view(type(self)) >> 5057 if result.ndim: >> 5058 # Set the mask >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc >> in filled(self, fill_value) >> 3388 return self._data >> 3389 else: >> -> 3390 result = self._data.copy() >> 3391 try: >> 3392 np.putmask(result, m, fill_value) >> >> MemoryError: >> {/code} >> >> >> This is more a NumPy issue than anything else. We need to know >> the min and the max of the array in order to automatically scale >> the colormap for display. Therefore, we query the array object >> for its min/max. Because we support masked arrays, the array is >> first cast as a masked array, and then these queries are done. >> >> It appears that in numpy's masked array module, it calculates the >> array's min by making a copy of itself first. I would have >> figured that it would have done its task differently. In the >> meantime, I suspect you can work around this problem by explicitly >> setting the vmin/vmax keyword arguments to imshow if you know >> them. Therefore, there should be no need to determine the array's >> min/max in this inefficient manner. >> >> Ben Root >> > > Hi Ben, > I tried adding vmin & vmax the the imshow call but I still get a > MemoryError. > The grid file is 1.15 GB and I have ~4.5 out of 8 GB of memory > available when I launch ipython, 3.5 when I execute imshow and 2 > when I execute plt.draw(). mpl simply is not designed for image-type operations on huge arrays, vastly larger than what can be displayed. It is up to the user to down-sample or otherwise reduce the size of the array fed to imshow. > > > Well, it looks like setting vmin/vmax helped, because your traceback Did a new traceback get posted in a message that was not sent to the list? I found only the original traceback. > shows that the code made significant progress. The issue here is that > the process_value() method doesn't make a lot of sense. I am not sure > what is the rationale behind its logic. Hopefully, someone else can > chime in with an explanation of what is going on. Normalization has to handle all sorts of inputs--masked or not, all sorts of numbers, scalar or array--and it is much easier to do this efficiently if all these possibilities are reduced to a very few at the start. Specifically, it needs to supply a copy of the input (so that normalization doesn't change the original) in a floating point masked array, using float32 if possible for space efficiency. It needs to keep track of whether the input was a scalar, so that normalization can return a scalar when given a scalar input. Eric > > In the meantime, are you using a 32 or 64-bit machine? > > Ben Root > > > > ------------------------------------------------------------------------------ > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
On Sep 7, 2012, at 5:00 PM, Benjamin Root <ben...@ou...> wrote: > > > On Fri, Sep 7, 2012 at 9:49 AM, Shahar Shani-Kadmiel <ka...@po...> wrote: > On Sep 7, 2012, at 4:25 PM, Benjamin Root wrote: > >> >> >> On Fri, Sep 7, 2012 at 8:44 AM, Shahar Shani-Kadmiel <ka...@po...> wrote: >> 1. an ipython session is invoked with qtconsole --pylab >> 2. I load a large NetCDF grid (Grid file format: nf (# 18) GMT netCDF format (float) (COARDS-compliant) [DEFAULT]), approx. 1.15 GB >> 3. I then try to plot with imshow the data >> >> added below are the lines leading up to the error and the error itself. >> >> >> This is running on OS X 10.7.4 with a recently installed EPD 7.3. >> >> >> {code} >> from scipy.io import netcdf_file as netcdf >> data = netcdf('srtm_43_44_05_06_07_08.grd','r').variables['z'][::-1] >> >> fig, ax = subplots() >> >> data.shape >> Out[5]: (24004, 12002) >> >> im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), interpolation='none') >> --------------------------------------------------------------------------- >> MemoryError Traceback (most recent call last) >> <ipython-input-6-f92e4c4c63b5> in <module>() >> ----> 1 im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), interpolation='none') >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs) >> 6743 im.set_clim(vmin, vmax) >> 6744 else: >> -> 6745 im.autoscale_None() >> 6746 im.set_url(url) >> 6747 >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py in autoscale_None(self) >> 281 if self._A is None: >> 282 raise TypeError('You must first set_array for mappable') >> --> 283 self.norm.autoscale_None(self._A) >> 284 self.changed() >> 285 >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py in autoscale_None(self, A) >> 889 ' autoscale only None-valued vmin or vmax' >> 890 if self.vmin is None: >> --> 891 self.vmin = ma.min(A) >> 892 if self.vmax is None: >> 893 self.vmax = ma.max(A) >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc in min(obj, axis, out, fill_value) >> 5873 def min(obj, axis=None, out=None, fill_value=None): >> 5874 try: >> -> 5875 return obj.min(axis=axis, fill_value=fill_value, out=out) >> 5876 except (AttributeError, TypeError): >> 5877 # If obj doesn't have a max method, >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc in min(self, axis, out, fill_value) >> 5054 # No explicit output >> 5055 if out is None: >> -> 5056 result = self.filled(fill_value).min(axis=axis, out=out).view(type(self)) >> 5057 if result.ndim: >> 5058 # Set the mask >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc in filled(self, fill_value) >> 3388 return self._data >> 3389 else: >> -> 3390 result = self._data.copy() >> 3391 try: >> 3392 np.putmask(result, m, fill_value) >> >> MemoryError: >> {/code} >> >> This is more a NumPy issue than anything else. We need to know the min and the max of the array in order to automatically scale the colormap for display. Therefore, we query the array object for its min/max. Because we support masked arrays, the array is first cast as a masked array, and then these queries are done. >> >> It appears that in numpy's masked array module, it calculates the array's min by making a copy of itself first. I would have figured that it would have done its task differently. In the meantime, I suspect you can work around this problem by explicitly setting the vmin/vmax keyword arguments to imshow if you know them. Therefore, there should be no need to determine the array's min/max in this inefficient manner. >> >> Ben Root >> > > Hi Ben, > I tried adding vmin & vmax the the imshow call but I still get a MemoryError. > The grid file is 1.15 GB and I have ~4.5 out of 8 GB of memory available when I launch ipython, 3.5 when I execute imshow and 2 when I execute plt.draw(). > > Well, it looks like setting vmin/vmax helped, because your traceback shows that the code made significant progress. The issue here is that the process_value() method doesn't make a lot of sense. I am not sure what is the rationale behind its logic. Hopefully, someone else can chime in with an explanation of what is going on. > > In the meantime, are you using a 32 or 64-bit machine? > > Ben Root > I am on a 64 bit machine but 32 bit distro of Enthought.
On Fri, Sep 7, 2012 at 9:49 AM, Shahar Shani-Kadmiel <ka...@po... > wrote: > On Sep 7, 2012, at 4:25 PM, Benjamin Root wrote: > > > > On Fri, Sep 7, 2012 at 8:44 AM, Shahar Shani-Kadmiel < > ka...@po...> wrote: > >> 1. an ipython session is invoked with qtconsole --pylab >> 2. I load a large NetCDF grid (Grid file format: nf (# 18) GMT netCDF >> format (float) (COARDS-compliant) [DEFAULT]), approx. 1.15 GB >> 3. I then try to plot with imshow the data >> >> added below are the lines leading up to the error and the error itself. >> >> >> This is running on OS X 10.7.4 with a recently installed EPD 7.3. >> >> >> {code} >> from scipy.io import netcdf_file as netcdf >> data = netcdf('srtm_43_44_05_06_07_08.grd','r').variables['z'][::-1] >> >> fig, ax = subplots() >> >> data.shape >> Out[5]: (24004, 12002) >> >> im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), >> interpolation='none') >> >> --------------------------------------------------------------------------- >> MemoryError Traceback (most recent call >> last) >> <ipython-input-6-f92e4c4c63b5> in <module>() >> ----> 1 im = ax.imshow(data, >> aspect=((data.shape[1])/float(data.shape[0])), interpolation='none') >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py >> in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, >> origin, extent, shape, filternorm, filterrad, imlim, resample, url, >> **kwargs) >> 6743 im.set_clim(vmin, vmax) >> 6744 else: >> -> 6745 im.autoscale_None() >> 6746 im.set_url(url) >> 6747 >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py >> in autoscale_None(self) >> 281 if self._A is None: >> 282 raise TypeError('You must first set_array for >> mappable') >> --> 283 self.norm.autoscale_None(self._A) >> 284 self.changed() >> 285 >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py >> in autoscale_None(self, A) >> 889 ' autoscale only None-valued vmin or vmax' >> 890 if self.vmin is None: >> --> 891 self.vmin = ma.min(A) >> 892 if self.vmax is None: >> 893 self.vmax = ma.max(A) >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc >> in min(obj, axis, out, fill_value) >> 5873 def min(obj, axis=None, out=None, fill_value=None): >> 5874 try: >> -> 5875 return obj.min(axis=axis, fill_value=fill_value, out=out) >> 5876 except (AttributeError, TypeError): >> 5877 # If obj doesn't have a max method, >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc >> in min(self, axis, out, fill_value) >> 5054 # No explicit output >> 5055 if out is None: >> -> 5056 result = self.filled(fill_value).min(axis=axis, >> out=out).view(type(self)) >> 5057 if result.ndim: >> 5058 # Set the mask >> >> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc >> in filled(self, fill_value) >> 3388 return self._data >> 3389 else: >> -> 3390 result = self._data.copy() >> 3391 try: >> 3392 np.putmask(result, m, fill_value) >> >> MemoryError: >> {/code} >> > > This is more a NumPy issue than anything else. We need to know the min > and the max of the array in order to automatically scale the colormap for > display. Therefore, we query the array object for its min/max. Because we > support masked arrays, the array is first cast as a masked array, and then > these queries are done. > > It appears that in numpy's masked array module, it calculates the array's > min by making a copy of itself first. I would have figured that it would > have done its task differently. In the meantime, I suspect you can work > around this problem by explicitly setting the vmin/vmax keyword arguments > to imshow if you know them. Therefore, there should be no need to > determine the array's min/max in this inefficient manner. > > Ben Root > > > Hi Ben, > I tried adding vmin & vmax the the imshow call but I still get a > MemoryError. > The grid file is 1.15 GB and I have ~4.5 out of 8 GB of memory available > when I launch ipython, 3.5 when I execute imshow and 2 when I execute > plt.draw(). > Well, it looks like setting vmin/vmax helped, because your traceback shows that the code made significant progress. The issue here is that the process_value() method doesn't make a lot of sense. I am not sure what is the rationale behind its logic. Hopefully, someone else can chime in with an explanation of what is going on. In the meantime, are you using a 32 or 64-bit machine? Ben Root
On Sep 7, 2012, at 4:25 PM, Benjamin Root wrote: > > > On Fri, Sep 7, 2012 at 8:44 AM, Shahar Shani-Kadmiel <ka...@po...> wrote: > 1. an ipython session is invoked with qtconsole --pylab > 2. I load a large NetCDF grid (Grid file format: nf (# 18) GMT netCDF format (float) (COARDS-compliant) [DEFAULT]), approx. 1.15 GB > 3. I then try to plot with imshow the data > > added below are the lines leading up to the error and the error itself. > > > This is running on OS X 10.7.4 with a recently installed EPD 7.3. > > > {code} > from scipy.io import netcdf_file as netcdf > data = netcdf('srtm_43_44_05_06_07_08.grd','r').variables['z'][::-1] > > fig, ax = subplots() > > data.shape > Out[5]: (24004, 12002) > > im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), interpolation='none') > --------------------------------------------------------------------------- > MemoryError Traceback (most recent call last) > <ipython-input-6-f92e4c4c63b5> in <module>() > ----> 1 im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), interpolation='none') > > /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs) > 6743 im.set_clim(vmin, vmax) > 6744 else: > -> 6745 im.autoscale_None() > 6746 im.set_url(url) > 6747 > > /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py in autoscale_None(self) > 281 if self._A is None: > 282 raise TypeError('You must first set_array for mappable') > --> 283 self.norm.autoscale_None(self._A) > 284 self.changed() > 285 > > /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py in autoscale_None(self, A) > 889 ' autoscale only None-valued vmin or vmax' > 890 if self.vmin is None: > --> 891 self.vmin = ma.min(A) > 892 if self.vmax is None: > 893 self.vmax = ma.max(A) > > /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc in min(obj, axis, out, fill_value) > 5873 def min(obj, axis=None, out=None, fill_value=None): > 5874 try: > -> 5875 return obj.min(axis=axis, fill_value=fill_value, out=out) > 5876 except (AttributeError, TypeError): > 5877 # If obj doesn't have a max method, > > /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc in min(self, axis, out, fill_value) > 5054 # No explicit output > 5055 if out is None: > -> 5056 result = self.filled(fill_value).min(axis=axis, out=out).view(type(self)) > 5057 if result.ndim: > 5058 # Set the mask > > /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc in filled(self, fill_value) > 3388 return self._data > 3389 else: > -> 3390 result = self._data.copy() > 3391 try: > 3392 np.putmask(result, m, fill_value) > > MemoryError: > {/code} > > This is more a NumPy issue than anything else. We need to know the min and the max of the array in order to automatically scale the colormap for display. Therefore, we query the array object for its min/max. Because we support masked arrays, the array is first cast as a masked array, and then these queries are done. > > It appears that in numpy's masked array module, it calculates the array's min by making a copy of itself first. I would have figured that it would have done its task differently. In the meantime, I suspect you can work around this problem by explicitly setting the vmin/vmax keyword arguments to imshow if you know them. Therefore, there should be no need to determine the array's min/max in this inefficient manner. > > Ben Root > Hi Ben, I tried adding vmin & vmax the the imshow call but I still get a MemoryError. The grid file is 1.15 GB and I have ~4.5 out of 8 GB of memory available when I launch ipython, 3.5 when I execute imshow and 2 when I execute plt.draw(). im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), interpolation=None, vmin=-400., vmax=3000.) plt.draw() --------------------------------------------------------------------------- MemoryError Traceback (most recent call last) /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 53 def draw_wrapper(artist, renderer, *args, **kwargs): 54 before(artist, renderer) ---> 55 draw(artist, renderer, *args, **kwargs) 56 after(artist, renderer) 57 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/figure.py in draw(self, renderer) 882 dsu.sort(key=itemgetter(0)) 883 for zorder, func, args in dsu: --> 884 func(*args) 885 886 renderer.close_group('figure') /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 53 def draw_wrapper(artist, renderer, *args, **kwargs): 54 before(artist, renderer) ---> 55 draw(artist, renderer, *args, **kwargs) 56 after(artist, renderer) 57 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py in draw(self, renderer, inframe) 1981 1982 for zorder, a in dsu: -> 1983 a.draw(renderer) 1984 1985 renderer.close_group('axes') /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 53 def draw_wrapper(artist, renderer, *args, **kwargs): 54 before(artist, renderer) ---> 55 draw(artist, renderer, *args, **kwargs) 56 after(artist, renderer) 57 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/image.py in draw(self, renderer, *args, **kwargs) 353 warnings.warn("Image will not be shown correctly with this backend.") 354 --> 355 im = self.make_image(renderer.get_image_magnification()) 356 if im is None: 357 return /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/image.py in make_image(self, magnification) 573 im, xmin, ymin, dxintv, dyintv, sx, sy = \ 574 self._get_unsampled_image(self._A, [_x1, _x2, _y1, _y2], --> 575 transformed_viewLim) 576 577 fc = self.axes.patch.get_facecolor() /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/image.py in _get_unsampled_image(self, A, image_extents, viewlim) 200 else: 201 if self._rgbacache is None: --> 202 x = self.to_rgba(self._A, self._alpha, bytes=True) 203 self._rgbacache = x 204 else: /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py in to_rgba(self, x, alpha, bytes) 211 pass 212 x = ma.asarray(x) --> 213 x = self.norm(x) 214 x = self.cmap(x, alpha=alpha, bytes=bytes) 215 return x /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py in __call__(self, value, clip) 843 clip = self.clip 844 --> 845 result, is_scalar = self.process_value(value) 846 847 self.autoscale_None(result) /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py in process_value(value) 829 if result.dtype.kind == 'f': 830 if isinstance(value, np.ndarray): --> 831 result = result.copy() 832 elif result.dtype.itemsize > 2: 833 result = result.astype(np.float) /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc in __call__(self, *args, **params) 2449 mask = instance._mask 2450 cls = type(instance) -> 2451 result = getattr(data, methodname)(*args, **params).view(cls) 2452 result._update_from(instance) 2453 if result.ndim: MemoryError:
On Fri, Sep 7, 2012 at 8:44 AM, Shahar Shani-Kadmiel <ka...@po... > wrote: > 1. an ipython session is invoked with qtconsole --pylab > 2. I load a large NetCDF grid (Grid file format: nf (# 18) GMT netCDF > format (float) (COARDS-compliant) [DEFAULT]), approx. 1.15 GB > 3. I then try to plot with imshow the data > > added below are the lines leading up to the error and the error itself. > > > This is running on OS X 10.7.4 with a recently installed EPD 7.3. > > > {code} > from scipy.io import netcdf_file as netcdf > data = netcdf('srtm_43_44_05_06_07_08.grd','r').variables['z'][::-1] > > fig, ax = subplots() > > data.shape > Out[5]: (24004, 12002) > > im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), > interpolation='none') > --------------------------------------------------------------------------- > MemoryError Traceback (most recent call last) > <ipython-input-6-f92e4c4c63b5> in <module>() > ----> 1 im = ax.imshow(data, > aspect=((data.shape[1])/float(data.shape[0])), interpolation='none') > > /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py > in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, > origin, extent, shape, filternorm, filterrad, imlim, resample, url, > **kwargs) > 6743 im.set_clim(vmin, vmax) > 6744 else: > -> 6745 im.autoscale_None() > 6746 im.set_url(url) > 6747 > > /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py > in autoscale_None(self) > 281 if self._A is None: > 282 raise TypeError('You must first set_array for > mappable') > --> 283 self.norm.autoscale_None(self._A) > 284 self.changed() > 285 > > /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py > in autoscale_None(self, A) > 889 ' autoscale only None-valued vmin or vmax' > 890 if self.vmin is None: > --> 891 self.vmin = ma.min(A) > 892 if self.vmax is None: > 893 self.vmax = ma.max(A) > > /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc > in min(obj, axis, out, fill_value) > 5873 def min(obj, axis=None, out=None, fill_value=None): > 5874 try: > -> 5875 return obj.min(axis=axis, fill_value=fill_value, out=out) > 5876 except (AttributeError, TypeError): > 5877 # If obj doesn't have a max method, > > /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc > in min(self, axis, out, fill_value) > 5054 # No explicit output > 5055 if out is None: > -> 5056 result = self.filled(fill_value).min(axis=axis, > out=out).view(type(self)) > 5057 if result.ndim: > 5058 # Set the mask > > /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc > in filled(self, fill_value) > 3388 return self._data > 3389 else: > -> 3390 result = self._data.copy() > 3391 try: > 3392 np.putmask(result, m, fill_value) > > MemoryError: > {/code} > This is more a NumPy issue than anything else. We need to know the min and the max of the array in order to automatically scale the colormap for display. Therefore, we query the array object for its min/max. Because we support masked arrays, the array is first cast as a masked array, and then these queries are done. It appears that in numpy's masked array module, it calculates the array's min by making a copy of itself first. I would have figured that it would have done its task differently. In the meantime, I suspect you can work around this problem by explicitly setting the vmin/vmax keyword arguments to imshow if you know them. Therefore, there should be no need to determine the array's min/max in this inefficient manner. Ben Root
1. an ipython session is invoked with qtconsole --pylab 2. I load a large NetCDF grid (Grid file format: nf (# 18) GMT netCDF format (float) (COARDS-compliant) [DEFAULT]), approx. 1.15 GB 3. I then try to plot with imshow the data added below are the lines leading up to the error and the error itself. This is running on OS X 10.7.4 with a recently installed EPD 7.3. {code} from scipy.io import netcdf_file as netcdf data = netcdf('srtm_43_44_05_06_07_08.grd','r').variables['z'][::-1] fig, ax = subplots() data.shape Out[5]: (24004, 12002) im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), interpolation='none') --------------------------------------------------------------------------- MemoryError Traceback (most recent call last) <ipython-input-6-f92e4c4c63b5> in <module>() ----> 1 im = ax.imshow(data, aspect=((data.shape[1])/float(data.shape[0])), interpolation='none') /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs) 6743 im.set_clim(vmin, vmax) 6744 else: -> 6745 im.autoscale_None() 6746 im.set_url(url) 6747 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/cm.py in autoscale_None(self) 281 if self._A is None: 282 raise TypeError('You must first set_array for mappable') --> 283 self.norm.autoscale_None(self._A) 284 self.changed() 285 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/colors.py in autoscale_None(self, A) 889 ' autoscale only None-valued vmin or vmax' 890 if self.vmin is None: --> 891 self.vmin = ma.min(A) 892 if self.vmax is None: 893 self.vmax = ma.max(A) /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc in min(obj, axis, out, fill_value) 5873 def min(obj, axis=None, out=None, fill_value=None): 5874 try: -> 5875 return obj.min(axis=axis, fill_value=fill_value, out=out) 5876 except (AttributeError, TypeError): 5877 # If obj doesn't have a max method, /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc in min(self, axis, out, fill_value) 5054 # No explicit output 5055 if out is None: -> 5056 result = self.filled(fill_value).min(axis=axis, out=out).view(type(self)) 5057 if result.ndim: 5058 # Set the mask /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/ma/core.pyc in filled(self, fill_value) 3388 return self._data 3389 else: -> 3390 result = self._data.copy() 3391 try: 3392 np.putmask(result, m, fill_value) MemoryError: {/code}
Hi all, I have just received the following information from John's family regarding the memorial service: John's memorial service will be held on Monday, October 1, 2012, at 11.a.m. at Rockefeller Chapel at the University of Chicago. The exact address is 5850 S. Woodlawn Ave, Chicago, IL 60615. The service is open to the public. The service will be fully planned and scripted with no room for people to eulogize, however, we will have a reception after the service, hosted by Tradelink, where people can talk. Regards, f
On 2012年09月06日 9:03 PM, Phil Elson wrote: > This seems to a be common misconception... > > I guess in future, we could add a check to the add_patch method to see > if the given artist already has an associated Axes, and if it does, emit > a warning. It's not just patches; but I think a single warning in Artist.add_axes would do it, perhaps at the cost of generating an unnecessary warning for some legitimate use case. Eric > > > > On 7 September 2012 07:42, Eric Firing <ef...@ha... > <mailto:ef...@ha...>> wrote: > > On 2012年09月06日 8:35 PM, jonasr wrote: > > That seems to work, thank you. > > > > I would have thought that the add_patch function creates two seperate > > objects independent of the defined Rectangle. > > add_patch doesn't create any objects; it just attaches the axes to the > patch in both directions: a reference to the patch object is appended to > a list of axes artists, and the patch object gets a reference to the > axes. Fortunately, python has garbage collection to handle such > circular references. > > Eric > > > > > greets jonas > > > ------------------------------------------------------------------------------ > 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 > Mat...@li... > <mailto:Mat...@li...> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >
This seems to a be common misconception... I guess in future, we could add a check to the add_patch method to see if the given artist already has an associated Axes, and if it does, emit a warning. On 7 September 2012 07:42, Eric Firing <ef...@ha...> wrote: > On 2012年09月06日 8:35 PM, jonasr wrote: > > That seems to work, thank you. > > > > I would have thought that the add_patch function creates two seperate > > objects independent of the defined Rectangle. > > add_patch doesn't create any objects; it just attaches the axes to the > patch in both directions: a reference to the patch object is appended to > a list of axes artists, and the patch object gets a reference to the > axes. Fortunately, python has garbage collection to handle such > circular references. > > Eric > > > > > greets jonas > > > > ------------------------------------------------------------------------------ > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
On 2012年09月06日 8:35 PM, jonasr wrote: > That seems to work, thank you. > > I would have thought that the add_patch function creates two seperate > objects independent of the defined Rectangle. add_patch doesn't create any objects; it just attaches the axes to the patch in both directions: a reference to the patch object is appended to a list of axes artists, and the patch object gets a reference to the axes. Fortunately, python has garbage collection to handle such circular references. Eric > > greets jonas
That seems to work, thank you. I would have thought that the add_patch function creates two seperate objects independent of the defined Rectangle. greets jonas -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Rectangle-Bug-tp38825p38828.html Sent from the matplotlib - users mailing list archive at Nabble.com.
On Thursday, September 6, 2012, jonasr wrote: > Hello, > > i spotted a bug in the Rectangle function when plotting with multiple > subplot, here is a source code example: > > #!/usr/bin/env python > # -*- coding: utf-8 -*- > > from matplotlib.pyplot import * > from numpy import * > import sys, os > > def main(): > f, axs = subplots(1,2) > > x=arange(0,10,0.001) > y=sin(x) > axs[0].plot(x,y,"blue")#,alpha=1) > axs[1].plot(x,y,"blue",alpha=1) > > rect = Rectangle((0,0), 1, 1, facecolor="blue",alpha=1) > axs[0].add_patch(rect) > axs[1].add_patch(rect) > > show() > return 0 > > if __name__ == '__main__': > main() > > this script should plot two sin functions and a rectangle in both subplots > . > the rectangle doesn't seem to appear until i move the area from the left > subplot (where the rectangle should appear) > over to the second subplot. > here is an example how it looks like: > http://www.imagebanana.com/view/hzm8bjro/example.png > > if i remove the command > axs[1].add_patch(rect) > the problem doesn't seem to appear > > my current matplotlib version is: '1.1.1rc' > os is ubuntu 12.04 > > greetz jonas > > > > Not a bug. An artist, such as the rectangle patch, can only reliably work in one axes object at a time. It can not be in two places at once. Make two rectangles and attach each to an axes, and it will work. Cheers! Ben Root
On closer inspection the problem isn't calling it from another file, it is calling it from wxpython. Not exactly sure how to copy code... lasso_test.py ----- from matplotlib.widgets import Lasso from matplotlib.nxutils import points_inside_poly from matplotlib.colors import colorConverter from matplotlib.collections import RegularPolyCollection from matplotlib.pyplot import figure, show from numpy import nonzero from numpy.random import rand from scipy import linspace, polyval, polyfit, sqrt, stats, randn class Datum: colorin = colorConverter.to_rgba('red') colorout = colorConverter.to_rgba('green') def __init__(self, x, y, include=False): self.x = x self.y = y if include: self.color = self.colorin else: self.color = self.colorout class LassoManager: def __init__(self, ax, data): self.axes = ax self.canvas = ax.figure.canvas self.data = data self.Nxy = len(data) facecolors = [d.color for d in data] self.xys = [(d.x, d.y) for d in data] fig = ax.figure self.collection = RegularPolyCollection( fig.dpi, 6, sizes=(100,), facecolors=facecolors, offsets = self.xys, transOffset = ax.transData) ax.add_collection(self.collection) self.cid = self.canvas.mpl_connect('button_press_event', self.onpress) self.ind = None def callback(self, verts): if hasattr(self, 'temp'): self.temp.pop(0).remove() facecolors = self.collection.get_facecolors() ind = nonzero(points_inside_poly(self.xys, verts))[0] selected = [] for i in range(self.Nxy): if i in ind: facecolors[i] = Datum.colorin selected.append(self.xys[i]) else: facecolors[i] = Datum.colorout xs = [] ys = [] for n in selected: xs.append(n[0]) ys.append(n[1]) (ar,br) = polyfit(xs,ys,1) t = linspace(min(xs),max(xs)) print('ar=%s br=%s' % (ar,br)) xr = polyval([ar,br],t) self.temp = self.axes.plot(t,xr,'-',c='b') self.canvas.draw_idle() self.canvas.widgetlock.release(self.lasso) del self.lasso self.ind = ind def onpress(self, event): print('clicked') if self.canvas.widgetlock.locked(): return if event.inaxes is None: return self.lasso = Lasso(event.inaxes, (event.xdata, event.ydata), self.callback) # acquire a lock on the widget drawing # self.canvas.widgetlock(self.lasso) class start_lasso(): def __init__(self): data = [Datum(*xy) for xy in rand(100, 2)] fig = figure() ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) lman = LassoManager(ax, data) show() -------------------------------- call_lasso.py ---- import wx import lasso_test class MyFrame(wx.Frame): """ We simply derive a new class of Frame. """ def __init__(self, parent, title): wx.Frame.__init__(self, parent, title=title, size=(200,100)) button = wx.Button(self, label='Open Lasso') self.Bind(wx.EVT_BUTTON, self.open_lasso, button) self.Show(True) def open_lasso(self, event): lasso_test.start_lasso() app = wx.App(False) frame = MyFrame(None, 'Small editor') app.MainLoop() ----------------------------- Thanks, Mark On Wed, Sep 5, 2012 at 5:15 PM, Tony Yu <ts...@gm...> wrote: > > > On Wed, Sep 5, 2012 at 7:19 PM, Mark Budde <mar...@gm...> wrote: >> >> Hi, >> I'm not an expert so please go easy on me. I am using the pyplot lasso >> demo, and have got it to work how I would like. I am having a problem, >> however, where I cannot get it to work if my python file is not the >> main file (where __name__ is not __main__). >> >> I took the part at the bottom in the "if __name__ == '__main__':" and >> put it into a class. Everything works fine if I call the class from >> within the same file. However, if I call the class from another file, >> the graph loads fine but the lasso tool does not work. Troubleshooting >> revealed that LassoManager.onpress is not being called when I click >> the mouse. Any suggestions are welcome because this is driving me >> crazy! >> Thanks, >> Mark >> > > Hi Mark, > > I can't seem to reproduce your issue, but it's a bit difficult without > seeing how exactly you wrapped up the "main" part of the code. Just > guessing: maybe the two cases aren't *exactly* the same. > > Is it possible that you have ``lman`` (the LassoManager instance) defined in > the same block of code as ``show`` in one case but not the other? If, for > example, ``lman`` is defined in a method of your class, but not saved > anywhere then it'll get discarded after the method finishes. So ``show`` > would need to be called inside that method, or saved as a class attribute. > > Like I said, that's just a wild guess. You should paste the class def if > you're still having problems. > > Best > -Tony > > P.S. If you're running matplotlib from Github master, you might be > interested in an alternative lasso tool (LassoSelector) that may be simpler > to use.: > https://github.com/matplotlib/matplotlib/blob/master/examples/widgets/lasso_selector_demo.py >
Hello, i spotted a bug in the Rectangle function when plotting with multiple subplot, here is a source code example: #!/usr/bin/env python # -*- coding: utf-8 -*- from matplotlib.pyplot import * from numpy import * import sys, os def main(): f, axs = subplots(1,2) x=arange(0,10,0.001) y=sin(x) axs[0].plot(x,y,"blue")#,alpha=1) axs[1].plot(x,y,"blue",alpha=1) rect = Rectangle((0,0), 1, 1, facecolor="blue",alpha=1) axs[0].add_patch(rect) axs[1].add_patch(rect) show() return 0 if __name__ == '__main__': main() this script should plot two sin functions and a rectangle in both subplots . the rectangle doesn't seem to appear until i move the area from the left subplot (where the rectangle should appear) over to the second subplot. here is an example how it looks like: http://www.imagebanana.com/view/hzm8bjro/example.png if i remove the command axs[1].add_patch(rect) the problem doesn't seem to appear my current matplotlib version is: '1.1.1rc' os is ubuntu 12.04 greetz jonas -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Rectangle-Bug-tp38825.html Sent from the matplotlib - users mailing list archive at Nabble.com.
Thats the plan. The problem is clicking on a plot calls both onpick and onpress (hence the additional fig.canvas.draw() to work around this). ill put a flag in and do an if/else on that as well
On Thu, Sep 6, 2012 at 4:37 PM, Jon Roadley-Battin < jon...@gm...> wrote: > On 6 September 2012 14:55, Jon Roadley-Battin > <jon...@gm...> wrote: > > On 6 September 2012 14:20, Benjamin Root <ben...@ou...> wrote: > >> > >> > >> On Thu, Sep 6, 2012 at 5:29 AM, Jon Roadley-Battin > >> <jon...@gm...> wrote: > >>> > >>> Good morning, > >>> > >>> I have an odd problem with saving plot images via the navigation bar > >>> (unsure if it is unique to the navigation bar) if I have added custom > >>> text. > >>> > >>> BACKGROUND. > >>> I have a python gui which is used to connect to some hardware as a > >>> diagnosis tool. Its a pyGTK program and on one ui tab there is an > >>> embeded matplotlib plot. > >>> Now some of the signals I plot rather than being a waveform is more of > >>> a collection of flags (16bit but thats a by and by) > >>> eg: > >>> > >>> > >>> > >>> > >>> fault > >>> 0 = fault1 > >>> 0 = fault2 > >>> 1 = fault3 > >>> 0 = fault4 > >>> > >>> > >>> > >>> so for this I can plot this and it will show 2 (possibly changing > w.r.t. > >>> time). > >>> I then hook in via a onpick event such that if I click on a plot I > >>> essentially do this: > >>> > >>> self.figtxt = > >>> self.fig.text(0.79,0.92,'\n'.join(txt),va='top', > >>> bbox=dict(boxstyle='round', facecolor='white',alpha=0.7)) > >>> self.plot_marker = > >>> > self.plot_area.plot(xdata,ydata,'x',color=event.artist.get_color(),ms=7) > >>> > >>> ie I put a cross where someone clicked (for indication) and I also > >>> create a texxbox which lists human readable version of what bits are > >>> set. > >>> Great, really helpful in debugging. > >>> > >>> The issue is if you click on the save image icon on the navigation > >>> toolbar it saves the waveform and legend BUT not the additional > >>> content (the cross and the textbox). > >>> > >>> > >>> any idea as to how todo this? > >>> > >> > >> What you are describing should work as expected. Is it possible that > you > >> could make a simple, self-contained version (hopefully it doesn't need > to be > >> embedded to reproduce the problem)? Maybe a modification of one of the > >> existing examples in the online docs might be able to reproduce your > issue? > >> > >> Ben Root > >> > > > > Good afternoon, > > I agree it should work and the examples i have run allow this so this > > is why I am looking over my specifics. > > The only thing I can see is the examples call to add txt via an axes > > entity, I have been doing it via a figure entity. > > > > I am going to re-write to draw on the axis (last time I did this it > > didn't display hence going for a figure). > > > > If this doesn't work I shall strip the code down to a minimum example > > demonstrating what I am describing > > Well I have narrowed down exactly what causes it and produced a > stripped down piece of code that reproduces the effect. > > It is related to events. I use mpl_connect to connect two functions > #1 onpick - when a plot is picked annotate plot (in practice IF it is > a binary array then annotate) > #2 onpress - click anywhere else and it clears said annotation. > > Works well (probably not the best way todo this, but it works). Thing > is it seems my onpress method is called when I click on the save on > the toolbar > > I guess I should add an if statement ( if event.inaxis ...) so that > the remove method isn't called outside of the axes area > > Yup, that would do it. Because of how you structured your try/except statement in onpress(), the canvas is only re-drawn upon any unsuccessful attempts of removing the text. So, after you save, you still see the text objects there because the canvas hasn't been redrawn. Doing a test for "event.inaxes" is the correct way to go there (and making sure you do the draw at the right situation). Cheers! Ben Root
On 6 September 2012 14:55, Jon Roadley-Battin <jon...@gm...> wrote: > On 6 September 2012 14:20, Benjamin Root <ben...@ou...> wrote: >> >> >> On Thu, Sep 6, 2012 at 5:29 AM, Jon Roadley-Battin >> <jon...@gm...> wrote: >>> >>> Good morning, >>> >>> I have an odd problem with saving plot images via the navigation bar >>> (unsure if it is unique to the navigation bar) if I have added custom >>> text. >>> >>> BACKGROUND. >>> I have a python gui which is used to connect to some hardware as a >>> diagnosis tool. Its a pyGTK program and on one ui tab there is an >>> embeded matplotlib plot. >>> Now some of the signals I plot rather than being a waveform is more of >>> a collection of flags (16bit but thats a by and by) >>> eg: >>> >>> >>> >>> >>> fault >>> 0 = fault1 >>> 0 = fault2 >>> 1 = fault3 >>> 0 = fault4 >>> >>> >>> >>> so for this I can plot this and it will show 2 (possibly changing w.r.t. >>> time). >>> I then hook in via a onpick event such that if I click on a plot I >>> essentially do this: >>> >>> self.figtxt = >>> self.fig.text(0.79,0.92,'\n'.join(txt),va='top', >>> bbox=dict(boxstyle='round', facecolor='white',alpha=0.7)) >>> self.plot_marker = >>> self.plot_area.plot(xdata,ydata,'x',color=event.artist.get_color(),ms=7) >>> >>> ie I put a cross where someone clicked (for indication) and I also >>> create a texxbox which lists human readable version of what bits are >>> set. >>> Great, really helpful in debugging. >>> >>> The issue is if you click on the save image icon on the navigation >>> toolbar it saves the waveform and legend BUT not the additional >>> content (the cross and the textbox). >>> >>> >>> any idea as to how todo this? >>> >> >> What you are describing should work as expected. Is it possible that you >> could make a simple, self-contained version (hopefully it doesn't need to be >> embedded to reproduce the problem)? Maybe a modification of one of the >> existing examples in the online docs might be able to reproduce your issue? >> >> Ben Root >> > > Good afternoon, > I agree it should work and the examples i have run allow this so this > is why I am looking over my specifics. > The only thing I can see is the examples call to add txt via an axes > entity, I have been doing it via a figure entity. > > I am going to re-write to draw on the axis (last time I did this it > didn't display hence going for a figure). > > If this doesn't work I shall strip the code down to a minimum example > demonstrating what I am describing Well I have narrowed down exactly what causes it and produced a stripped down piece of code that reproduces the effect. It is related to events. I use mpl_connect to connect two functions #1 onpick - when a plot is picked annotate plot (in practice IF it is a binary array then annotate) #2 onpress - click anywhere else and it clears said annotation. Works well (probably not the best way todo this, but it works). Thing is it seems my onpress method is called when I click on the save on the toolbar I guess I should add an if statement ( if event.inaxis ...) so that the remove method isn't called outside of the axes area #!/usr/bin/env python from matplotlib.pyplot import figure, show import numpy as np fig = figure() text = None x = np.arange(0,10,0.2) y = np.arange(10,20,0.2) ax = fig.add_subplot(111) ax.plot(x,y,picker=5) def onpick(event): global text x = event.artist.get_xdata()[event.ind][0] y = event.artist.get_ydata()[event.ind][0] text = ax.annotate('foo',xy=(x,y),xytext=(0.8, 0.9),textcoords='axes fraction') fig.canvas.draw() def onpress(event): global text try: text.remove() except: fig.canvas.draw() fig.canvas.mpl_connect('button_press_event', onpress) fig.canvas.mpl_connect('pick_event', onpick) show()