Re: [Matplotlib-users] cannot plot in loops with matplotlib 0.99. 0.98 works fine
Thanks JJ, but unfortunately this is not the solution. draw() gives the same result. - and I am running this as a script (running it from ipython shell). Any clue? Jae-Joon Lee wrote: > > I presume you're running that script in interactive shell? > Try draw() instead of show(). > > Regards, > > -JJ > > > On Sun, Sep 6, 2009 at 3:06 PM, tva wrote: >> >> Hi all >> >> with matplotlib 0.98.5.3 this script will draw new lines as the scrips is >> running: >> >> from pylab import * >> x = arange(0,2*pi,0.01) >> for i in arange(1,20): >> >> y=sin(x+i) >> plot(x,y) # update the data >> show() >> >> >> with matplotlib 0.99, the exact same script runs to the end without >> plotting >> and then plots all the lines. This is just a trivial example but for some >> applications it is useful to monitor the evolution of curves as the >> script >> is running - allows me to update parameters if something diverges. >> Any idea why there is such a difference between 0.98.5.3 and 0.99 ?? >> -- >> View this message in context: >> http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25320454.html >> Sent from the matplotlib - users mailing list archive at Nabble.com. >> >> >> -- >> 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 mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- View this message in context: http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25326025.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- 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
[Matplotlib-users] Re : slow rendering of 2K images using Animation_blit_tk.py - bis
OK, thanks JJ, I just wanted to make sure I was not missing something. I guess I'll have to check how it goes once rebinned. Cheers, Auré De : Jae-Joon Lee À : Auré Gourrier Cc : matplotlib-users@lists.sourceforge.net Envoyé le : Lundi, 7 Septembre 2009, 4h11mn 29s Objet : Re: [Matplotlib-users] slow rendering of 2K images using Animation_blit_tk.py - bis There are a few ways to improve the speed, which, I guess, will give you factor of a few speed up. If you need more than that, I guess matplotlib is not suitable for your purpose. * try a simple interpolation method, eg. imshow(arr, interpolation="nearest") * reduce the image size. Unless you have a monitor this large, you loose the image quality anyhow. In my machine (linux, xeon 2.6 GHz), it takes about ~0.8 s to display 2k x 2k image. 0.3 s for 1k x 1k. Regards, -JJ On Fri, Sep 4, 2009 at 5:18 AM, Auré Gourrier wrote: > Dear all, > > I recently cried for help (see below) but sadly didn't get any answer... > This problem is really a bottleneck for me and if I must find a solution... > Can anyone PLEASE point me in the right direction ? > > I recently bumped into a problem while trying to display imshow images > (2048x2048 pix) in a GUI based on TkAgg (matplotib0.91.2, python 2..4.4, > numpy1.0.4).. In brief, building the image with imshow is Ok, but the call to > show() or draw() takes about 1.2 s on my system (XP, 2.8Ghz, 2Go ram). After > reading a lot of posts and trying out a few things, I turned to the > Animation_blit_tk.py example and modified it accordingly (code attached > below). In the end, the display is still not much faster using this method > (still in the order of 1.2 s as indicated by the result below). > Could any one tel me whether I'm doing something wrong ? > > As far as I understand, at least in my Tk GUI, the limiting step using the > ImageTk.FigureCanvasTkAgg is the call to draw() or draw_artist(). I read > some comments from John regarding TkAgg being slow in some cases but > couldn't find a definite answer. > > Any hint would be much appreciated > > Cheers, > > Aure > > > > # For detailed comments on animation and the techniqes used here, see > # the wiki entry http://www.scipy.org/Cookbook/Matplotlib/Animations > > import matplotlib > matplotlib.use('TkAgg') > > import sys > import pylab as p > #import matplotlib.numerix as nx > import time > > from FileUtils10 import fileHandling > > # for profiling > tstart = time.time() > tprevious = time.time() > > fnamelist = ['fname1','fname2','fname3'] > > ax = p.subplot(111) > canvas = ax.figure.canvas > > print 't1 ',time.time()-tprevious > tprevious = time.time() > > # create the initial line > dataarr = fileHandling(fnamelist[0]).readSpecial() > #print dataarr.dtype=> numpy dtype uint16 > #dataarr = dataarr..astype('uint8') > print 't2 ',time.time()-tprevious > tprevious = time.time() > > image = p.imshow(dataarr, animated=True) > print 't3 ',time.time()-tprevious > tprevious = time.time() > > def run(*args): > tprevious = time.time() > background = canvas.copy_from_bbox(ax.bbox) > print 't4 ',time.time()-tprevious > tprevious = time.time() > while 1: > #print fnamelist[run.cnt] > # restore the clean slate background > canvas.restore_region(background) > print 't5 ',time.time()-tprevious > tprevious = time.time() > # update the data > dataarr = fileHandling(fnamelist[run.cnt]).readSpecial() > print 't6 ',time.time()-tprevious > tprevious = time.time() > image.set_data(dataarr) > print 't7 ',time.time()-tprevious > tprevious = time.time() > # just draw the animated artist > ax.draw_artist(image) > print 't8 ',time.time()-tprevious > tprevious = time.time() > # just redraw the axes rectangle > canvas.blit(ax.bbox) > print 't9 ',time.time()-tprevious > tprevious = time.time() > > if fnamelist[run.cnt] == fnamelist[-1]: > # print the timing info and quit > print 'total time:' , time.time()-tstart > print 'FPS:' , 1000./(time.time()-tstart) > p.close('all') > sys.exit() > > run.cnt += 1 > run.cnt = 0 > > > p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs > p.grid() # to ensure proper background restore > manager = p.get_current_fig_manager() > manager.window.after(100, run) > > p.show() > > > > Results in: > > t1 0.85867575 > t2 0.032648499 > t3 1.3126376 > t4 0.0 > t5 0.0 > t6 0.0310001373291 > t7 0.0 > t8 1.1873624 > t9 0.016324249 > t5 0.0 > t6 0.046313354 > t7 0..0 > t8 1.17200016975 > t9 0.0149998664856 > t5 0.0 > t6 0.047000169754 > t7 0.0 > t8 1.21899986267 > t9 0.0 > t5 0.0 > t6 0.046038147 > t7 0.0 > t8 1.1713134 > t9 0.0 > t5 0.0 > t6 0.046313354 > t7 0.0 > t8 1.187
Re: [Matplotlib-users] cannot plot in loops with matplotlib 0.99. 0.98 works fine
> Any idea why there is such a difference between > 0.98.5.3 and 0.99 ?? Drawing the whole figure once, when no further Python input is available, is much more efficient than drawing after each plot() command. For some figures, matplotlib 0.98.5.3 becomes extremely slow. > Thanks JJ, but unfortunately this is not the solution. > draw() gives the same result. - and I am running this > as a script (running it from ipython shell). The problem in your script is that the event loop never kicks in. Unfortunately, Python has no support for event loops in general, which makes this hard to solve. One option is to use raw_input() between calls to plot(), but then each time you have to hit to get the script to proceed. --Michiel. --- On Mon, 9/7/09, tva wrote: > From: tva > Subject: Re: [Matplotlib-users] cannot plot in loops with matplotlib 0.99. > 0.98 works fine > To: matplotlib-users@lists.sourceforge.net > Date: Monday, September 7, 2009, 3:17 AM > > Thanks JJ, but unfortunately this is not the solution. > draw() gives the same > result. - and I am running this as a script (running it > from ipython shell). > > Any clue? > > > > > > Jae-Joon Lee wrote: > > > > I presume you're running that script in interactive > shell? > > Try draw() instead of show(). > > > > Regards, > > > > -JJ > > > > > > On Sun, Sep 6, 2009 at 3:06 PM, tva > wrote: > >> > >> Hi all > >> > >> with matplotlib 0.98.5.3 this script will draw new > lines as the scrips is > >> running: > >> > >> from pylab import * > >> x = arange(0,2*pi,0.01) > >> for i in arange(1,20): > >> > >> y=sin(x+i) > >> plot(x,y) # update the data > >> show() > >> > >> > >> with matplotlib 0.99, the exact same script runs > to the end without > >> plotting > >> and then plots all the lines. This is just a > trivial example but for some > >> applications it is useful to monitor the evolution > of curves as the > >> script > >> is running - allows me to update parameters if > something diverges. > >> Any idea why there is such a difference between > 0.98.5.3 and 0.99 ?? > >> -- > >> View this message in context: > >> http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25320454.html > >> Sent from the matplotlib - users mailing list > archive at Nabble.com. > >> > >> > >> > -- > >> 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 mailing list > > Matplotlib-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > -- > View this message in context: > http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25326025.html > Sent from the matplotlib - users mailing list archive at > Nabble.com. > > > -- > 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 mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] cannot plot in loops with matplotlib 0.99. 0.98 works fine
Hi Michiel thanks, but does that explain why the script works smoothly in 0.98.6 and earlier versions? Plotting all the curves at the end of the script is certainly possible, but it is a severe reduction of the functionallity. given the fact that it works so well in earlier versions of matplotlib, it seems like a bug in matplotlib...? Michiel de Hoon wrote: > >> Any idea why there is such a difference between >> 0.98.5.3 and 0.99 ?? > > Drawing the whole figure once, when no further Python input is available, > is much more efficient than drawing after each plot() command. For some > figures, matplotlib 0.98.5.3 becomes extremely slow. > >> Thanks JJ, but unfortunately this is not the solution. >> draw() gives the same result. - and I am running this >> as a script (running it from ipython shell). > > The problem in your script is that the event loop never kicks in. > Unfortunately, Python has no support for event loops in general, which > makes this hard to solve. One option is to use raw_input() between calls > to plot(), but then each time you have to hit to get the script to > proceed. > > --Michiel. > > > --- On Mon, 9/7/09, tva wrote: > >> From: tva >> Subject: Re: [Matplotlib-users] cannot plot in loops with matplotlib >> 0.99. 0.98 works fine >> To: matplotlib-users@lists.sourceforge.net >> Date: Monday, September 7, 2009, 3:17 AM >> >> Thanks JJ, but unfortunately this is not the solution. >> draw() gives the same >> result. - and I am running this as a script (running it >> from ipython shell). >> >> Any clue? >> >> >> >> >> >> Jae-Joon Lee wrote: >> > >> > I presume you're running that script in interactive >> shell? >> > Try draw() instead of show(). >> > >> > Regards, >> > >> > -JJ >> > >> > >> > On Sun, Sep 6, 2009 at 3:06 PM, tva >> wrote: >> >> >> >> Hi all >> >> >> >> with matplotlib 0.98.5.3 this script will draw new >> lines as the scrips is >> >> running: >> >> >> >> from pylab import * >> >> x = arange(0,2*pi,0.01) >> >> for i in arange(1,20): >> >> >> >> y=sin(x+i) >> >> plot(x,y) # update the data >> >> show() >> >> >> >> >> >> with matplotlib 0.99, the exact same script runs >> to the end without >> >> plotting >> >> and then plots all the lines. This is just a >> trivial example but for some >> >> applications it is useful to monitor the evolution >> of curves as the >> >> script >> >> is running - allows me to update parameters if >> something diverges. >> >> Any idea why there is such a difference between >> 0.98.5.3 and 0.99 ?? >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25320454.html >> >> Sent from the matplotlib - users mailing list >> archive at Nabble.com. >> >> >> >> >> >> >> -- >> >> 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 mailing list >> > Matplotlib-users@lists.sourceforge.net >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25326025.html >> Sent from the matplotlib - users mailing list archive at >> Nabble.com. >> >> >> -- >> 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 C
[Matplotlib-users] Fetching a data slab with NetCDFFile
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/ in () /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
Re: [Matplotlib-users] cannot plot in loops with matplotlib 0.99. 0.98 works fine
Problem solved. The backend was set to Qt4Agg. Once set to TkAgg everything works. I don't get it but it works.. tva wrote: > > Hi Michiel > > thanks, but does that explain why the script works smoothly in 0.98.6 and > earlier versions? > Plotting all the curves at the end of the script is certainly possible, > but it is a severe reduction of the functionallity. given the fact that it > works so well in earlier versions of matplotlib, it seems like a bug in > matplotlib...? > > > > > Michiel de Hoon wrote: >> >>> Any idea why there is such a difference between >>> 0.98.5.3 and 0.99 ?? >> >> Drawing the whole figure once, when no further Python input is available, >> is much more efficient than drawing after each plot() command. For some >> figures, matplotlib 0.98.5.3 becomes extremely slow. >> >>> Thanks JJ, but unfortunately this is not the solution. >>> draw() gives the same result. - and I am running this >>> as a script (running it from ipython shell). >> >> The problem in your script is that the event loop never kicks in. >> Unfortunately, Python has no support for event loops in general, which >> makes this hard to solve. One option is to use raw_input() between calls >> to plot(), but then each time you have to hit to get the script >> to proceed. >> >> --Michiel. >> >> >> --- On Mon, 9/7/09, tva wrote: >> >>> From: tva >>> Subject: Re: [Matplotlib-users] cannot plot in loops with matplotlib >>> 0.99. 0.98 works fine >>> To: matplotlib-users@lists.sourceforge.net >>> Date: Monday, September 7, 2009, 3:17 AM >>> >>> Thanks JJ, but unfortunately this is not the solution. >>> draw() gives the same >>> result. - and I am running this as a script (running it >>> from ipython shell). >>> >>> Any clue? >>> >>> >>> >>> >>> >>> Jae-Joon Lee wrote: >>> > >>> > I presume you're running that script in interactive >>> shell? >>> > Try draw() instead of show(). >>> > >>> > Regards, >>> > >>> > -JJ >>> > >>> > >>> > On Sun, Sep 6, 2009 at 3:06 PM, tva >>> wrote: >>> >> >>> >> Hi all >>> >> >>> >> with matplotlib 0.98.5.3 this script will draw new >>> lines as the scrips is >>> >> running: >>> >> >>> >> from pylab import * >>> >> x = arange(0,2*pi,0.01) >>> >> for i in arange(1,20): >>> >> >>> >> y=sin(x+i) >>> >> plot(x,y) # update the data >>> >> show() >>> >> >>> >> >>> >> with matplotlib 0.99, the exact same script runs >>> to the end without >>> >> plotting >>> >> and then plots all the lines. This is just a >>> trivial example but for some >>> >> applications it is useful to monitor the evolution >>> of curves as the >>> >> script >>> >> is running - allows me to update parameters if >>> something diverges. >>> >> Any idea why there is such a difference between >>> 0.98.5.3 and 0.99 ?? >>> >> -- >>> >> View this message in context: >>> >> >>> http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25320454.html >>> >> Sent from the matplotlib - users mailing list >>> archive at Nabble.com. >>> >> >>> >> >>> >> >>> -- >>> >> 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 mailing list >>> > Matplotlib-users@lists.sourceforge.net >>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> > >>> > >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/cannot-plot-in-loops-with-matplotlib-0.99.-0.98-works-fine-tp25320454p25326025.html >>> Sent from the matplotlib - users mailing list archive at >>> Nabble.com. >>> >>> >>> -- >>> 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] grid on log-plots
Hi, can anybody tell me how to get gridlines in a logarithmic plot? i tried eg.: loglog([1,10,100], [1,10,100]) grid(True) but neither the grid is drawn, nor an error occur. When i make a linear plot, grid(True) works fine and draws the grid. (win32, python 2.6, matplotlib 0.99) Thanks -- 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
[Matplotlib-users] Ploting Date
Oi, I'm having trouble ploting some values vs date with matplotlib. I get the data from an SQL server using the _mssql module after the query I tried populating the list using: [code] xls = [] yls = [] for row in conn: xls.append(row['Ia']) yls.append(row['tiempo']) [/code] The row['tiempo'] is datetime in the SQL table so I get yls filled with datetime objects At first I tried displaying it in an MMDDhhmm format using [code] temp = row['tiempo'] temp = str(temp.year) + '-' + str(temp.month) + '-' + str(temp.hour) +'-' + str(temp.minute) temp = int(temp) yls.append(temp) [/code] but after seeing that matplotlib by default uses an exponential notation y then realized that the scale would be off. If I use date2num() it displays numbers not dates. Basically I would like to plot the data against dates, with the ability to autoscale from a minutes view to a month view at least. The data set is failry large, at least 1 year of data from 5 minutes apart measurements. Any pointers in the right direction? Can I plot dates without converting them to a number? If not could the numbers be linked to back to the date and the date be displayed in the axis instead of the numbers? Thanks for your time. -- 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
Re: [Matplotlib-users] Segmentation fault with EPS output on matplotlib >=0.98.5.2
I'm using 'xpdf' now, I think it must be ghostscript acting up. I only need eps output infrequently so I'll stick with this workaround for the moment. On Mon, Sep 7, 2009 at 4:28 AM, Jae-Joon Lee wrote: > I cannot reproduce this error. > And I'm not sure if this is a bug in matplotlib or ghostscript. > You may try to use different distiller. > > pl.rc('ps', usedistiller="xpdf") > > In my machine, both ghostscript and xpdf option works fine. > But my gs version is different than yours > > GPL Ghostscript 8.61 (2007-11-21) > > If the xpdf option woks, I think it is more likely that this is a bug in > gs. > > Regards, > > -JJ > > > On Wed, Sep 2, 2009 at 9:22 AM, Ewald Zietsman > wrote: > > Hi All, > > > > I'm trying to make a simple errorbar plot which gets saved to an EPS > file. I > > paste the code below. For some weird reason, the savefig line causes a > > segmentation fault in ghostscript. when I use (in this case, on my > computer) > > 206 points or more. It doesn't happen if I comment the "pl.rc('text', > > usetex=True)" line out nor does it happen if I comment the pl.savefig > line > > out. This happens in matplotlib 0.99 and 0.98.5.2. Any help will be > greatly > > appreciated. > > > > > > Regards, > > > > Ewald Zietsman > > > > #test.py > > > > import matplotlib.pyplot as pl > > import numpy as np > > > > pl.rc('text', usetex=True) > > pl.rc('font', family='serif') > > > > N = 206 > > x1 = np.linspace(-10,10,N) > > e1 = np.random.randn(N) > > > > pl.errorbar(x1, x1, yerr=e1, fmt='k.') > > pl.savefig('test.eps') > > pl.show() > > > > > > The error message: > > > > python test.py > > Segmentation fault > > Traceback (most recent call last): > > File "test.py", line 16, in > > pl.savefig('test.eps') > > File "/usr/lib/python2.5/site-packages/matplotlib/pyplot.py", line 345, > in > > savefig > > return fig.savefig(*args, **kwargs) > > File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line 990, > in > > savefig > > self.canvas.print_figure(*args, **kwargs) > > File "/usr/lib/python2.5/site-packages/matplotlib/backend_bases.py", > line > > 1419, in print_figure > > **kwargs) > > File "/usr/lib/python2.5/site-packages/matplotlib/backend_bases.py", > line > > 1308, in print_eps > > return ps.print_eps(*args, **kwargs) > > File > "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_ps.py", > > line 869, in print_eps > > return self._print_ps(outfile, 'eps', *args, **kwargs) > > File > "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_ps.py", > > line 892, in _print_ps > > orientation, isLandscape, papertype) > > File > "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_ps.py", > > line 1148, in _print_figure_tex > > else: gs_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox) > > File > "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_ps.py", > > line 1268, in gs_distill > > your image.\nHere is the full report generated by ghostscript:\n\n' + > > fh.read()) > > RuntimeError: ghostscript was not able to process your image. > > Here is the full report generated by ghostscript: > > > > GPL Ghostscript 8.63 (2008-08-01) > > Copyright (C) 2008 Artifex Software, Inc. All rights reserved. > > This software comes with NO WARRANTY: see the file PUBLIC for details. > > Loading CenturySchL-Roma font from > > /var/lib/defoma/gs.d/dirs/fonts/c059013l.pfb... 3423696 1832182 6023256 > > 4166010 1 done. > > > > > > > -- > > 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 mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] grid on log-plots
jihi wrote: > ... can anybody tell me how to get gridlines in a logarithmic plot? ... from matplotlib.pyplot import * plot([1,10,100],[1,10,100]) grid() yscale('log') xscale('log') works here. best, sebastian. signature.asc Description: OpenPGP digital signature -- 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
Re: [Matplotlib-users] cannot plot in loops with matplotlib 0.99. 0.98 works fine
On Mon, Sep 7, 2009 at 1:02 PM, tva wrote: > > Problem solved. The backend was set to Qt4Agg. Once set to TkAgg everything > works. > I don't get it but it works.. > > I think an explicit call of draw() in the interactive mode (e.g. with ipython -pylab) should update the figure canvas immediately. And this is the behavior I currently observe with Gtk and Wx backend. If the Qt4 backend behaves differently, I guess this is a bug. I don't have the qt4 backend installed, and I hope other developers take a look. -JJ -- 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
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 wrote: > 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/ in () > > > /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.s