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
(13) |
2
(3) |
3
(4) |
4
(24) |
5
(12) |
6
(11) |
7
(14) |
8
(17) |
9
(3) |
10
(5) |
11
(23) |
12
(7) |
13
(9) |
14
(17) |
15
(1) |
16
(2) |
17
(2) |
18
(11) |
19
(14) |
20
(9) |
21
(13) |
22
(12) |
23
(1) |
24
|
25
(7) |
26
(11) |
27
(20) |
28
(19) |
29
(11) |
30
(1) |
Stuart Yarrow wrote: > Hi All, > > An extra label is appearing on the plot I'm generating. I wonder if anyone > could explain what it means/how to get rid of it? > > The plot is available at http://test.outpost.org.uk/example.png - the > unexplained label is the '+4.05674e7' in the upper right hand corner. This > value doesn't appear to be related to what I'm doing numerically. > > # Plot Results > lines1 = [] > plot1 = pylab.subplot(211) > lines1.extend(pylab.plot(In, thrust / g, 'b-')) > pylab.ylabel('Thrust (kgf)') > pylab.grid(True) > ax2 = pylab.twinx() > lines1.extend(pylab.plot(In, inputFlow * 60000, 'g--')) Couldn't it be because of "inputFlow * 60000", which may cause the plotted values to be large (so it is related to what you do numerically)? The same happens for e.g. plot(array([1,2,3])+1e5), i.e. if the values' changes are small compared to their magnitude. Without that, the tick numbers would read 100001.0, 100002.0, 100003.0 in this example, which may not look very pretty. HTH -- cheers, steve Random number generation is the art of producing pure gibberish as quickly as possible.
Hello, I am quite new to matplotlib. I'm drawing some points on a figure and have implemented a pick_event callback, in order to show something near the point I click. Now the problem is that when I show the text near the point, it hides a lot of other points, so I would like the text to dissapear (for example after some seconds). How could I do this ? (if it's possible) Btw, since I use matplotlib, I completely abandoned gnuplot. It's the best free plotting tool that I found. Thank you. Best regards, -- Alexandru Ionut Munteanu _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail
Bill, Thanks for your reply. pylab(ion) is not what I meant. Consider this simply script - ..... # simple.py from pylab import * plot([1,2,3]) show() .... Now, if I do python simple.py on a cmd prompt, this will open up a plot window, but the script won't return until the plot window is closed. I would like simple.py process to end but the plot window to be still up. I have users who would like to type one command after another and not have to close any of the plot windows created. I looked at ezplot, but it looks like a rather heavy weight soln, but maybe I need to do something similar. Is there any other way around this? Thanks, ss On 6/12/07, Bill Baxter <wb...@gm...> wrote: > > I'm not sure what you're after exactly, but your design needs may be > solved by calling pylab.ion(True). > If not the ezplot library that I wrote may do it for you. > http://www.python.org/pypi/ezplot/0.1.0a3 > > --bb > > On 6/13/07, signal seeker <see...@gm...> wrote: > > > > Hi All, > > > > I am very new to matplotlib and still trying to find my way through docs > and > > api, so please excuse me if there is a simple way to do this. > > > > So the situation is this - I would like to write a script that spawns > > multiple plots and exits, but the plots window do not die > > until they are explicitly closed. > > Is there a simple way to do this. All the examples that > > I have looked at so far have scripts that > > only exit once the call to show() returns. > > Is there some mechanism that > > matplotlib provides to make the show() return? I am of course using the > > pylab interface now, but I can start using the core matplotlib api if > need. > > Thanks in advance for your time. > > > > Regards, > > -ss > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > >
Hi All, An extra label is appearing on the plot I'm generating. I wonder if anyone could explain what it means/how to get rid of it? The plot is available at http://test.outpost.org.uk/example.png - the unexplained label is the '+4.05674e7' in the upper right hand corner. This value doesn't appear to be related to what I'm doing numerically. My plotting code is below (should probably tidy this up!): # Plot Results lines1 = [] plot1 = pylab.subplot(211) lines1.extend(pylab.plot(In, thrust / g, 'b-')) pylab.ylabel('Thrust (kgf)') pylab.grid(True) ax2 = pylab.twinx() lines1.extend(pylab.plot(In, inputFlow * 60000, 'g--')) pylab.ylabel('Flow (lpm)') pylab.legend(lines1, ('Thrust', 'Flow'), 2) #(0.02,0.8) plot1.set_xticklabels([]) pylab.title('%s / %s (%d lpm) / %d bar' % (self.thruster.name, self.valve.name, self.valve.ratedFlow * 60000, sysPres * 10**-5)) lines2 = [] plot2 = pylab.subplot(212) lines2.extend(pylab.plot(In, thrusterPower * 0.001, 'c--')) lines2.extend(pylab.plot(In, valvePower * 0.001, 'r:')) lines2.extend(pylab.plot(In, totalPower * 0.001, 'm-')) pylab.ylabel('Power (kW)') pylab.grid(True) ax4 = pylab.twinx() lines2.extend(pylab.plot(In, 1000 * efficiency / g, 'y-')) pylab.ylabel('Efficiency (kgf/kW)') pylab.xlabel('Control Current (normalised)') pylab.legend(lines2, ('Thruster', 'Valve', 'Total', 'Efficiency'), 2) #(0.02,0.6) pylab.savefig(filename, orientation='landscape') pylab.clf() Thanks in advance for any help/advice. -Stuart ----------------------------- Stuart Yarrow
On 2007年6月12日 13:34:35 -0500, "Johnny Lin" <jl...@jo...> said: > Hi all, > > I'm creating a cylindrical map, global in longitude and centered around > 180 and the equator, using the following code: > > map = Basemap( projection='cyl', resolution='l' > , llcrnrlon=0, urcrnrlon=360 > , llcrnrlat=-76.875, urcrnrlat=76.875 > , lon_0=180, lat_0=0 ) > map.drawmeridians(pylab.arange(0,361,45), labels=[0,0,0,1]) > > The result is a map with labels of 0, 45E, 90E, ... 45W, but without > a label at 0 (i.e. 360). Does anyone know how to make that label > come up? I'm running Python 2.4 in Mac OSX 10.4, with matplotlib > 0.90.1 and basemap 0.9.5. > > Thanks much! > > Best, > -Johnny > -- Johnny: The labels are drawn from 180E to 180W, and each longitude is only labelled once. That means you don't get a the wraparound longitude labelled at both the left and right side of the plot Sorry! -Jeff ------ Jeffrey S. Whitaker Phone: (303)497-6313 FAX: (303)497-6449 NOAA/OAR/CDC R/CDC1 325 Broadway, Boulder, CO, USA 80305-3328 http://www.cdc.noaa.gov/people/jeffrey.s.whitaker
Hello Andrew, Sorry for the delay, I have been on holidays. I wrote the code (such as it is - but the key line is adapted from the scipy web site). I should have put a copy of the BSD license at the front, I suppose, (would that be correct?) but it was never intended as more than a quick in-house solution to our problem. We have never "released" software to the outside world. It's not our focus. Brett. Andrew Straw <str...@as...> 02/06/2007 06:37 AM To bre...@un... cc Matplotlib Users <mat...@li...> Subject Re: [Matplotlib-users] Handling LARGE data sets bre...@un... wrote: > > Hi Alan, > > I'm not speaking for anyone else, but as far as I'm concerned that > code is public domain. > OK, well, who wrote the code and who holds the copyright? In other words, your concerns about the code being in the public domain may or may not be relevant, depending on where the code came from and whether you have any legal authority to distribute the code and under what conditions. It would be nice to include an SG filter in scipy, for example, but that would only be possible if it were released under a BSD-like license. -Andrew ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ UNITED GROUP This email message is the property of United Group. The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, you may not disclose, copy or distribute this email, nor take or omit to take any action in reliance on it. United Group accepts no liability for any damage caused by this email or any attachments due to viruses, interference, interception, corruption or unauthorised access. If you have received this email in error, please notify United Group immediately by email to the sender's email address and delete this document.
I'm not sure what you're after exactly, but your design needs may be solved by calling pylab.ion(True). If not the ezplot library that I wrote may do it for you. http://www.python.org/pypi/ezplot/0.1.0a3 --bb On 6/13/07, signal seeker <see...@gm...> wrote: > > Hi All, > > I am very new to matplotlib and still trying to find my way through docs and > api, so please excuse me if there is a simple way to do this. > > So the situation is this - I would like to write a script that spawns > multiple plots and exits, but the plots window do not die > until they are explicitly closed. > Is there a simple way to do this. All the examples that > I have looked at so far have scripts that > only exit once the call to show() returns. > Is there some mechanism that > matplotlib provides to make the show() return? I am of course using the > pylab interface now, but I can start using the core matplotlib api if need. > Thanks in advance for your time. > > Regards, > -ss > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >
Hi all, I'm creating a cylindrical map, global in longitude and centered around 180 and the equator, using the following code: map = Basemap( projection='cyl', resolution='l' , llcrnrlon=0, urcrnrlon=360 , llcrnrlat=-76.875, urcrnrlat=76.875 , lon_0=180, lat_0=0 ) map.drawmeridians(pylab.arange(0,361,45), labels=[0,0,0,1]) The result is a map with labels of 0, 45E, 90E, ... 45W, but without a label at 0 (i.e. 360). Does anyone know how to make that label come up? I'm running Python 2.4 in Mac OSX 10.4, with matplotlib 0.90.1 and basemap 0.9.5. Thanks much! Best, -Johnny -- ------------------------------------------- Johnny Lin | http://www.johnny-lin.com North Park University | Physics Department -------------------------------------------
Hi All, I am very new to matplotlib and still trying to find my way through docs and api, so please excuse me if there is a simple way to do this. So the situation is this - I would like to write a script that spawns multiple plots and exits, but the plots window do not die until they are explicitly closed. Is there a simple way to do this. All the examples that I have looked at so far have scripts that only exit once the call to show() returns. Is there some mechanism that matplotlib provides to make the show() return? I am of course using the pylab interface now, but I can start using the core matplotlib api if need. Thanks in advance for your time. Regards, -ss
Hi, I am plotting a number of polygons with different colours (results from an image clustering or classification algorithm). I'd like to have a map-like legend, with a square filled with some colour and some text describing what it is (a quick search in Google comes up with the following example: <https://secure.cityofno.com/Resources/Portal50/map_key.jpg>. Scary, though hopefully you get the gist of it :D). I realise that the legend class has some support for patches, but how does one go about using them? I can't just add a legend (I get a very messy legend, one for every patch in my plot). I should be able to set my legend somewhere, but I don't know where to start: pylab.legend? matplotlib.legend? Any hints or examples greatly appreciated! J
Eric Firing a écrit : > im = imshow(a) > cb = colorbar() > cs = contour(a, [0.8], norm = im.norm, cmap=im.cmap) > cb.add_lines(cs) > > Is this in fact what you want? Exactly, perfect ! Thanks a lot. Cheers, -- http://scipy.org/FredericPetit
John Hunter wrote: > BTW, numpy gurus, is there a better way to find the index in an array > that is minimal than > > indmin = int(numpy.nonzero(distances.min()==distances)[0]) yes -- see below. Also a few tweaks: > distances = numpy.array(numpy.sqrt((x-xs[event.ind])**2. + > (y-ys[event.ind])**2)) No need to call numpy.array on that, you're making a copy of what must be an array already. By the way, if you're not sure if it's an array, then you can use numpy.asarray(a) which won't make a copy if the argument is already an array. You can also use numpy.hypot() rather than explicitly calling sqrt(SumOfSquares): distances = numpy.hypot(x-xs[event.ind], y-ys[event.ind] ) (untested) or, if all you want is the closest one, you don't need to take the sqrt() at all: distances = ( (x-xs[event.ind])**2 + (y-ys[event.ind])**2 ) And don't use "2." in an exponent -- I think there is some optimization for integer exponents. > indmin = int(numpy.nonzero(distances.min()==distances)[0]) here you can use argmin: indmin = numpy.argmin(distances) of course, what you'd really want is a spatial index.... All untested.... -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no...
On 6/10/07, rolandreichel <rol...@we...> wrote: > I want to plot some timeseries (eg. stockcharts). I use now > DateLocator/Formatter, it works fine for me with the exeption, that > dataless periods on X-Axis (eg. weekends) are also plotted. Is there an > easy way to suppress them? Plot numpy.arange(len(xdata)) vs y and use a custom tick locator to format the integer index to date strings. Some of the code below is using svn (eg the csv2rec stuff) but the core logic of formatting date strings from integers works with any reasonably current mpl. # plot dates evenly spaced, eg skipping weekends import numpy from matplotlib.mlab import csv2rec from pylab import figure, show from matplotlib.dates import Formatter r = csv2rec('data/msft.csv')[-40:] class MyFormatter(Formatter): def __init__(self, dates, fmt='%Y-%m-%d'): self.dates = dates self.fmt = fmt def __call__(self, x, pos=0): 'Return the label for time x at position pos' ind = int(round(x)) if ind>=len(self.dates) or ind<=0: return '' return self.dates[ind].strftime(self.fmt) formatter = MyFormatter(r.date) fig = figure() ax = fig.add_subplot(111) ax.xaxis.set_major_formatter(formatter) ax.plot(numpy.arange(len(r)), r.close, 'o-') fig.autofmt_xdate() show()
On 6/11/07, Trevis Crane <t_...@mr...> wrote: > I've coded (with help from John) a plot of mine to allow a user to select a > data point, and when they click on it a new plot pops up. It works great. > However, some of the points are very close together and if I'm not extremely > careful in selecting the point, then multiple graphs pop up or I get the > wrong one entirely. You can always write a custom hit testing function -- see http://matplotlib.sourceforge.net/examples/pick_event_demo.py for an example. Probably easiest here is to just find the index which is closest to one of your data points and just plot that data set. BTW, numpy gurus, is there a better way to find the index in an array that is minimal than indmin = int(numpy.nonzero(distances.min()==distances)[0]) import numpy from pylab import figure, show X = numpy.random.rand(100, 200) xs = numpy.mean(X, axis=1) ys = numpy.std(X, axis=1) fig = figure() ax = fig.add_subplot(211) ax.set_title('click on point to plot time series') line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance ax2 = fig.add_subplot(212) def onpick(event): if event.artist!=line: return True N = len(event.ind) if not N: return True # the click locations x = event.mouseevent.xdata y = event.mouseevent.ydata distances = numpy.array(numpy.sqrt((x-xs[event.ind])**2. + (y-ys[event.ind])**2)) indmin = int(numpy.nonzero(distances.min()==distances)[0]) dataind = event.ind[indmin] print event.ind, distances, indmin, dataind, X[dataind][:5] ax2.cla() ax2.plot(X[dataind]) ax2.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]), transform=ax2.transAxes, va='top') ax2.set_ylim(-0.5, 1.5) fig.canvas.draw() return True fig.canvas.mpl_connect('pick_event', onpick) show()
>=20 > Hi Trevis, >=20 > <snip> >=20 > On 12/06/07, Trevis Crane <t_...@mr...> wrote: > > So, I figured maybe if I zoomed in then it'd be easier to select the desired > > point. The problem is that after zooming/panning, the mouse cursor changes > > and my click events are no longer recognized as such. Furthermore, I can't > > find a way to make the mouse cursor return to its normal state and allow me > > to continue clicking events. Is there something I'm missing? >=20 > Could it be that you're still in zoom or pan mode when you try to > click to select a point? You'll see the zoom or pan button highlighted > in the toolbar if that is the case. Clicks when in these modes don't > activate the callback feature, so you need to click again on the same > toolbar button to leave that mode; then the cursor should return to an > arrow and your callback routine should be activated correctly. [Trevis Crane]=20 I feel like a bonehead sometimes. That helps. I didn't know to click the button again to get out of pan/zoom mode. thanks, trevis =20 > HTH, >=20 > A. > -- > AJC McMorland, PhD Student > Physiology, University of Auckland >=20 > ------------------------------------------------------------------------ - > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
try using plot_date() function instead of plot() On Sun, 2007年06月10日 at 09:49 +0200, rolandreichel wrote: > Hi, > > I want to plot some timeseries (eg. stockcharts). I use now > DateLocator/Formatter, it works fine for me with the exeption, that > dataless periods on X-Axis (eg. weekends) are also plotted. Is there an > easy way to suppress them? > > regards > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Hi Trevis, <snip> On 12/06/07, Trevis Crane <t_...@mr...> wrote: > So, I figured maybe if I zoomed in then it'd be easier to select the desired > point. The problem is that after zooming/panning, the mouse cursor changes > and my click events are no longer recognized as such. Furthermore, I can't > find a way to make the mouse cursor return to its normal state and allow me > to continue clicking events. Is there something I'm missing? Could it be that you're still in zoom or pan mode when you try to click to select a point? You'll see the zoom or pan button highlighted in the toolbar if that is the case. Clicks when in these modes don't activate the callback feature, so you need to click again on the same toolbar button to leave that mode; then the cursor should return to an arrow and your callback routine should be activated correctly. HTH, A. -- AJC McMorland, PhD Student Physiology, University of Auckland
Hi, =20 I've coded (with help from John) a plot of mine to allow a user to select a data point, and when they click on it a new plot pops up. It works great. However, some of the points are very close together and if I'm not extremely careful in selecting the point, then multiple graphs pop up or I get the wrong one entirely. =20 =20 So, I figured maybe if I zoomed in then it'd be easier to select the desired point. The problem is that after zooming/panning, the mouse cursor changes and my click events are no longer recognized as such. Furthermore, I can't find a way to make the mouse cursor return to its normal state and allow me to continue clicking events. Is there something I'm missing? =20 thanks, trevis =20 ________________________________________________ =20 Trevis Crane Postdoctoral Research Assoc. Department of Physics University of Ilinois 1110 W. Green St. Urbana, IL 61801 =20 p: 217-244-8652 f: 217-244-2278 e: tc...@ui... ________________________________________________ =20
* John Hunter <jd...@gm...> [070611 16:20]: > So the answer of which is better is a question of skill level and > context, but my simple advice is to use the pylab syntax from the > interactive python shell (and "ipython -pylab" is ideal for this) and > the API everywhere else. Most of my scripts are variants of this: > > import numpy as npy > from pylab import figure, close, show > fig = figure() > ax = fig.add_subplot(111) > x = npy.arange(0,10.) > ax.plot(x) > show() Hello, is there also a (possible object oriented) way to show/print a given figure? Like fig.show() or fig.print_figure(). I need it because I have a script generating (returning) several plots, and the user should be able to print/show the plots he likes. At the moment I use: ipython -pylab from myscript import plotgenerator fig = plotgenerator() canvas = get_current_fig_manager().canvas canvas.figure = fig canvas.print_figure('myplot.png') Here plotgenerator does something like: from matplotlib.figure import Figure fig = Figure() ax = myplot.add_subplot(111) ax.plot(x) But its cumbersome, and canvas.show() doesn not work (it gives an exception). Best would be if fig.show() (popping up a new canvas) and fig.print_figure() worked. Best Regards, Roman
Hello everyone! I'm seeking help with real-time plotting using Python and MatPlotLib. I've encoutered several problems so far: 1. There is no function to just add a point to the existing curve, so each time the data is updated all the curve has to be redrawn. This is not a clean solution for the real-time plotting. 2. I'm trying to use threads in Python in order to be able to get the data and draw the curve at the same time. Sometimes it's working, and sometimes the graphics rendering just hangs. Moreover, if I try to use the Timer class for the plotting thread, it is invoked only one time. I wonder, if my threads are stirring with a graphical library ones. If there is no special thread handling with Tk, I'll investigate my code again. I'll appreciate any help. Thank you. Dendron. P.S.: Sorry, forgot to put a title in the previous post.
Hello everyone! I'm seeking help with real-time plotting using Python and MatPlotLib. I've encoutered several problems so far: 1. There is no function to just add a point to the existing curve, so each time the data is updated all the curve has to be redrawn. This is not a clean solution for the real-time plotting. 2. I'm trying to use threads in Python in order to be able to get the data and draw the curve at the same time. Sometimes it's working, and sometimes the graphics rendering just hangs. Moreover, if I try to use the Timer class for the plotting thread, it is invoked only one time. I wonder, if my threads are stirring with a graphical library ones. If there is no special thread handling with Tk, I'll investigate my code again. I'll appreciate any help. Thank you. Dendron.
Sorry for the repost, but I'm still struggling with this. I'm trying to replicate a plot like this: http://tinyurl.com/2uwjn8 In this case, the y-axis on the left (the black dots) is linear and the y-axis on the right (red data) is log base 2. I can't figure out how to do the following: 1. How do I display the right-hand y-axis so that is includes the range above 32 and below 0 (as in the linked figure)? When I try to include 0 or below in the axis range, I get a range error (because of the log function). When I do auto-range, it ranges from 2 to 32. But I want to include 0 (and below) in my figure. 2. How do I line up the centers of both axes. in this case, the y-axis on the left needs to have the 0 value lined up with the value of 2 on the y axis on the right. In other words, how to I move one y-axis relative to the other. This is the best I can do so far. http://tinyurl.com/yotf2b As you can see, I can't get the right axis as log2 and still keep the 0 values. I'd really like to have a log axis on the right, because some of those values (red) are quite high. Thanks for the advice.
> -----Original Message----- > From: John Hunter [mailto:jd...@gm...] > Sent: Monday, June 11, 2007 9:08 AM > To: Trevis Crane > Cc: mat...@li... > Subject: Re: [Matplotlib-users] out of curiosity... >=20 > On 6/11/07, Trevis Crane <t_...@mr...> wrote: >=20 > > Coming from MATLAB, I started using matplotlib in the same fashion (and was > > very appreciative of the similariry). That is, I would import pylab and > > call the plotting functions as necessary. However, after seeing some of how > > others are using matplotlib, it seems most people use axes object methods to > > take care of plotting needs. I'm now taking this approach as well, but I > > honestly don't know why I should (or if I should). Will someone explain to > > me why one approach is better or worse? > [Trevis Crane]=20 John, your explanation is great. Thanks for taking the time. trevis > matplotlib supports both because in different contexts one is often > superior to the other. >=20 > The main difference is that the pylab interface is stateful and > handles object instantiation when necessary. For example, when you do > "plot", it checks to see if there is a current axes and if so plots > into it, and if not creates a new axes. When the new axes function is > called, it checks to see if there is a current figure and inserts into > it if available, and if not creates one. So it is "stateful" because > under the hood it is tracking the current axes, figure and some other > stuff. >=20 > When working interactively from the shell or in short scripts, this is > a nice feature because it saves typing and syntactic overhead. When > working in the shell, eg in ipython -pyab mode, this is usually the > way I work. >=20 > In other contexts the convenience that these functions imply become a > liability, because you often want to have explicit control, eg "put > this axes in this figure and put this plot into this axes...". In a > web application server or a user interface application, this is > definitely the way to work. In scripts of moderate complexity it is > advisable. >=20 > The basic idea is that "explicit is better than implicit". Working > this way is a little harder at first, but by forcing yourself to > understand who is doing what where, you ultimately write better, more > stable, more maintainable code. >=20 > One thing most serious python programmers agree on is that >=20 > from something import * >=20 > is bad practice because you usually don't know what names are coming > from where, and it creates the possibility of latent bugs. Eg, pylab > used to have a "set" command which emulates the matlab command of the > same name. It is used to set handle graphics properties. This worked > fine, until python introduced the "set" builtin, which works like the > mathematical set. Then it became impossible do "from pylab import *" > and use the new python builtin "set", so we cleaned up all the old > code and renamed the function. The programmer who do >=20 > import pylab > pylab.set >=20 > was protected from these often subtle and difficult to detect bugs. >=20 > The import * idiom also makes it tricky to combine code from two > scripts or modules into one, because both may be importing different > namespaces with overlapping names. >=20 > I have found, however, when talking to science teachers who are trying > to introduce python/numpy/pylab/scipy into the classroom as a matlab > replacement that the 'from pylab import *' idiom is important to them, > because their students want something that "just works" and is about > as easy as matlab. Even though it is probably preferable in the > abstract to teach students good practices from the beginning, it might > raise the barrier to entry sufficiently that they simply use matlab > instead. These teachers are already facing a fair amount of > resistance in trying to get python introduced at all, and we should > make it as easy on them as possible. So I am not a zealot on this > issue. >=20 > The other reason it is good practice to use the explicit API calls is > that code which starts out its life as a small script often has a way > of growing into a large script, and then you begin sharing it with > your colleagues and maybe writing a web interface or a GUI application > built on it. Code written using the API can safely be dropped into > larger applications, whereas code written in pylab probably cannot > (imagine lots of different functions competing for the current figure > w/o knowledge of one another). >=20 > So the answer of which is better is a question of skill level and > context, but my simple advice is to use the pylab syntax from the > interactive python shell (and "ipython -pylab" is ideal for this) and > the API everywhere else. Most of my scripts are variants of this: >=20 > import numpy as npy > from pylab import figure, close, show > fig =3D figure() > ax =3D fig.add_subplot(111) > x =3D npy.arange(0,10.) > ax.plot(x) > show() >=20 > JDH
On 6/11/07, Trevis Crane <t_...@mr...> wrote: > Coming from MATLAB, I started using matplotlib in the same fashion (and was > very appreciative of the similariry). That is, I would import pylab and > call the plotting functions as necessary. However, after seeing some of how > others are using matplotlib, it seems most people use axes object methods to > take care of plotting needs. I'm now taking this approach as well, but I > honestly don't know why I should (or if I should). Will someone explain to > me why one approach is better or worse? matplotlib supports both because in different contexts one is often superior to the other. The main difference is that the pylab interface is stateful and handles object instantiation when necessary. For example, when you do "plot", it checks to see if there is a current axes and if so plots into it, and if not creates a new axes. When the new axes function is called, it checks to see if there is a current figure and inserts into it if available, and if not creates one. So it is "stateful" because under the hood it is tracking the current axes, figure and some other stuff. When working interactively from the shell or in short scripts, this is a nice feature because it saves typing and syntactic overhead. When working in the shell, eg in ipython -pyab mode, this is usually the way I work. In other contexts the convenience that these functions imply become a liability, because you often want to have explicit control, eg "put this axes in this figure and put this plot into this axes...". In a web application server or a user interface application, this is definitely the way to work. In scripts of moderate complexity it is advisable. The basic idea is that "explicit is better than implicit". Working this way is a little harder at first, but by forcing yourself to understand who is doing what where, you ultimately write better, more stable, more maintainable code. One thing most serious python programmers agree on is that from something import * is bad practice because you usually don't know what names are coming from where, and it creates the possibility of latent bugs. Eg, pylab used to have a "set" command which emulates the matlab command of the same name. It is used to set handle graphics properties. This worked fine, until python introduced the "set" builtin, which works like the mathematical set. Then it became impossible do "from pylab import *" and use the new python builtin "set", so we cleaned up all the old code and renamed the function. The programmer who do import pylab pylab.set was protected from these often subtle and difficult to detect bugs. The import * idiom also makes it tricky to combine code from two scripts or modules into one, because both may be importing different namespaces with overlapping names. I have found, however, when talking to science teachers who are trying to introduce python/numpy/pylab/scipy into the classroom as a matlab replacement that the 'from pylab import *' idiom is important to them, because their students want something that "just works" and is about as easy as matlab. Even though it is probably preferable in the abstract to teach students good practices from the beginning, it might raise the barrier to entry sufficiently that they simply use matlab instead. These teachers are already facing a fair amount of resistance in trying to get python introduced at all, and we should make it as easy on them as possible. So I am not a zealot on this issue. The other reason it is good practice to use the explicit API calls is that code which starts out its life as a small script often has a way of growing into a large script, and then you begin sharing it with your colleagues and maybe writing a web interface or a GUI application built on it. Code written using the API can safely be dropped into larger applications, whereas code written in pylab probably cannot (imagine lots of different functions competing for the current figure w/o knowledge of one another). So the answer of which is better is a question of skill level and context, but my simple advice is to use the pylab syntax from the interactive python shell (and "ipython -pylab" is ideal for this) and the API everywhere else. Most of my scripts are variants of this: import numpy as npy from pylab import figure, close, show fig = figure() ax = fig.add_subplot(111) x = npy.arange(0,10.) ax.plot(x) show() JDH
Coming from MATLAB, I started using matplotlib in the same fashion (and was very appreciative of the similariry). That is, I would import pylab and call the plotting functions as necessary. However, after seeing some of how others are using matplotlib, it seems most people use axes object methods to take care of plotting needs. I'm now taking this approach as well, but I honestly don't know why I should (or if I should). Will someone explain to me why one approach is better or worse? =20 thanks, trevis =20 ________________________________________________ =20 Trevis Crane Postdoctoral Research Assoc. Department of Physics University of Ilinois 1110 W. Green St. Urbana, IL 61801 =20 p: 217-244-8652 f: 217-244-2278 e: tc...@ui... ________________________________________________ =20