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
(2) |
2
(4) |
3
(16) |
4
(4) |
5
(15) |
6
(16) |
7
(6) |
8
(4) |
9
(9) |
10
(5) |
11
(8) |
12
(14) |
13
(19) |
14
(21) |
15
(8) |
16
(6) |
17
(10) |
18
(22) |
19
(15) |
20
(7) |
21
(21) |
22
(1) |
23
(6) |
24
(16) |
25
(12) |
26
(11) |
27
(27) |
28
(7) |
29
|
30
(4) |
31
(5) |
|
|
|
|
|
Hi list, I want to visualize Plots over time. This describes the data: [image: 3dplot.png] a) and b) are single scans, the cutting at the red bars is no problem. c) illustrates how they are done over time. d) is what I want. I think this plot<http://matplotlib.sourceforge.net/examples/axes_grid/demo_axes_grid2.html>could be a starting point, but I don’t really understand what’s done there. e) would be easier to do, like this plot<http://matplotlib.sourceforge.net/examples/mplot3d/polys3d_demo.html>, but information is lost this way (hidden behind higher values) it would be best to do the following: 1. plot one horizontal line vertically above each other (gapless), one for each scan (so the vertical axis is the time axis) 2. each line is displayed as a series of gradients directly next to to each other (gapless) 3. the starting and ending point of each gradient are determined by the horizontal position of two adjacent data points in the current scan 4. the colors of each gradient are determined by the vertical position of the two adjacent data points in the current scan, relative to the total maximum has anyone an idea how to do this? i am really a matplotlib noob. Philipp
> just make a numpy array out of your two lists, and you'll be able > to subtract one from the other. > > import numpy as np > top = np.array(top) > bot = np.array(bot) Thank you, Paul. That worked and I'm now able to display bar charts. I appreciate it. Best, Che
Daniel, Following on from Eric's comments, attached is the simplest example I could come up with to do what you want. For non-filled contours, the 'segs' (last few lines of the file) should be fairly self-explanatory, and this is hopefully what you want. If you are after filled contours, you will need to understand both the 'segs' and the 'kinds' - essentially the segs comprise one or more discontinuous closed line loops and the corresponding kinds indicate how the loops are split up, a 1 being a LINETO and a 2 being a MOVETO. This can get a little awkward, and I think that sometimes you need to deal with arrays of arrays but I can't completely remember all the details. You should bear in mind that this code delves into matplotlib internals and you need to be careful as 1) it bypasses various sanity checks, 2) the underlying code could change at any point in the future (it has quite a lot in the last year for example). Otherwise, I hope it helps! Ian
Benjamin Root, on 2011年01月27日 13:04, wrote: > I believe he would rather call the core function that contour uses to > do the heavy lifting. This was something that one can do in matlab, > btw. I don't have access to the source right now. What does contour > call to perform this calculation? matplotlib.contour.QuadContourSet - which in turn uses ContourSet, and both take ax as a required argument. They use matplotlib.contour._cntr which is Daniel Fulger, on 2011年01月27日 20:21, wrote: > no, I would like to suppress plotting entirely, avoid changing of > active figure and avoid handling figures or axis completely. > I m only interested in the contourset. I wonder if my post was > somehow sloppy. > > Yes, there are work-arounds like creating a dummy figure, similar to > your suggestion, and return focus to > the previously active figure. But plotting takes time and memory, is > not needed and requires several code lines. Once might be ok but > speed and memory is important. > Plotting with alpha=0 still requires figure and axis handling. > > So how can I switch off all figure and axis related actions and > savely call contourset = contour(x,y,...) that does nothing else than > return the contours? I understand better now, but as far as I could tell from poking inside the QuadContourSet code, there isn't a simple way to call the underlying machinery which generates the contours. You'll have to look at what QuadContourSet._contour_args does internally to see what what x, y, z should be, and then create a contour using C = matplotlib.contour._cntr.Cntr(x,y,z) and then for each level, do something like what QuadContourSet._get_allsegs_and_allkinds does C.trace(..) best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
On 01/27/2011 09:21 AM, Daniel Fulger wrote: >> >> Dear all, >> >> contourset = pyplot.contour(..) >> >> calculates the contourset but also grabs whatever figure is currently >> active *somewhere* in the entire code >> and whichever scope it was created. The contours are plotted into it. >> >> While I could possibly live with that, I would really like to >> suppress any plotting and grabbig of focus. Only the contourset >> should be calculated. >> >> I can't find anything that describes this. Everybody wants the plot, >> not me. >> >> I would like to avoid hte workaround to ask for the currently active >> figure (if!! there is one at all), store the number, and later return >> focus. Is there no switch parameter (in pyplot or for contour at >> least) that turns plotting off? >> >> Regards >> Daniel >> >> >>> >>> Hi Daniel, >>> >>> I'm not sure if this gets at what you're asking for, but if >>> you just want the contours plotted on a figure other than the >>> currently active one, grab a handle to some other axes and call >>> contour from the axes itself (the parameters are the same). >>> Here's what I mean: >>> >>> ----------- >>> f,ax =plt.subplots(1,1) #grab handles to figure and axes >>> # or, if you're using an older version of matplotlib, do: >>> # f=plt.figure();ax=plt.subplot(1,1,1) >>> >>> >>> f2,ax2 =plt.subplots(1,1) # "f" no longer active figure >>> ... >>> contourset = ax.contour(...) # draw to the old figure "f" >>> ----------- >>> >>> You can read more about the difference between using pyplot and >>> using the object-oriented api here: >>> >>> http://matplotlib.sourceforge.net/faq/usage_faq.html >>> >>> On the other hand, if you just want the contour to not show up, >>> you can pass it alpha=0.0 to make it completely transparent and >>> invisible (but it's still there) >>> >>> contourset = pyplot.contour(.., alpha=0.0) >>> # later call contourset.set_alpha(1.0) to make visible again >>> >>> best, >>> -- >>> Paul Ivanov > > Dear Paul, > > no, I would like to suppress plotting entirely, avoid changing of > active figure and avoid handling figures or axis completely. > I m only interested in the contourset. I wonder if my post was > somehow sloppy. > > Yes, there are work-arounds like creating a dummy figure, similar to > your suggestion, and return focus to > the previously active figure. But plotting takes time and memory, is > not needed and requires several code lines. Once might be ok but > speed and memory is important. > Plotting with alpha=0 still requires figure and axis handling. > > So how can I switch off all figure and axis related actions and > savely call contourset = contour(x,y,...) that does nothing else than > return the contours? Look at contour.py, specifically QuadCountourSet._process_args. You will see the call to _cntr.Cntr. That is the core class, implemented in extension code. The contour generation is in the method _get_allsegs_and_allkinds, via the call to the Cntr.trace() method. You will have to put together your own function to instantiate Cntr and call Cntr.trace for each level. A major refactoring could be done to separate the calculation from the plotting, maybe by making the ContourSet into a compound artist and putting the drawing into a draw() method instead of having it called in the __init__() method. Eric > > > Regards > Daniel >
C M, on 2011年01月27日 13:56, wrote: > bars = self.subplot.bar(self.final_dates, top-bot, bottom=bot, align='center') > > I get the error: > > TypeError: unsupported operand type(s) for -: 'list' and 'list' > > Because I am trying to subtract the "bots" list from the "tops" list. > In the example code I gave, bot and times were not lists but were a > 'numpy.ndarray' and a numpy.float64' object, respectfully, and I guess > the - operand can be used on them. > > How can I structure my data such that this can work? (For some reason > I have not had nearly this much confusion with plotting lines, just > bars). Che, just make a numpy array out of your two lists, and you'll be able to subtract one from the other. import numpy as np top = np.array(top) bot = np.array(bot) best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
> > Dear all, > > contourset = pyplot.contour(..) > > calculates the contourset but also grabs whatever figure is currently > active *somewhere* in the entire code > and whichever scope it was created. The contours are plotted into it. > > While I could possibly live with that, I would really like to > suppress any plotting and grabbig of focus. Only the contourset > should be calculated. > > I can't find anything that describes this. Everybody wants the plot, > not me. > > I would like to avoid hte workaround to ask for the currently active > figure (if!! there is one at all), store the number, and later return > focus. Is there no switch parameter (in pyplot or for contour at > least) that turns plotting off? > > Regards > Daniel > > >> >> Hi Daniel, >> >> I'm not sure if this gets at what you're asking for, but if >> you just want the contours plotted on a figure other than the >> currently active one, grab a handle to some other axes and call >> contour from the axes itself (the parameters are the same). >> Here's what I mean: >> >> ----------- >> f,ax =plt.subplots(1,1) #grab handles to figure and axes >> # or, if you're using an older version of matplotlib, do: >> # f=plt.figure();ax=plt.subplot(1,1,1) >> >> >> f2,ax2 =plt.subplots(1,1) # "f" no longer active figure >> ... >> contourset = ax.contour(...) # draw to the old figure "f" >> ----------- >> >> You can read more about the difference between using pyplot and >> using the object-oriented api here: >> >> http://matplotlib.sourceforge.net/faq/usage_faq.html >> >> On the other hand, if you just want the contour to not show up, >> you can pass it alpha=0.0 to make it completely transparent and >> invisible (but it's still there) >> >> contourset = pyplot.contour(.., alpha=0.0) >> # later call contourset.set_alpha(1.0) to make visible again >> >> best, >> -- >> Paul Ivanov Dear Paul, no, I would like to suppress plotting entirely, avoid changing of active figure and avoid handling figures or axis completely. I m only interested in the contourset. I wonder if my post was somehow sloppy. Yes, there are work-arounds like creating a dummy figure, similar to your suggestion, and return focus to the previously active figure. But plotting takes time and memory, is not needed and requires several code lines. Once might be ok but speed and memory is important. Plotting with alpha=0 still requires figure and axis handling. So how can I switch off all figure and axis related actions and savely call contourset = contour(x,y,...) that does nothing else than return the contours? Regards Daniel
On Thursday, January 27, 2011, Paul Ivanov <piv...@gm...> wrote: > Daniel Fulger, on 2011年01月27日 18:16, wrote: >> Dear all, >> >> contourset = pyplot.contour(..) >> >> calculates the contourset but also grabs whatever figure is currently >> active *somewhere* in the entire code >> and whichever scope it was created. The contours are plotted into it. >> >> While I could possibly live with that, I would really like to >> suppress any plotting and grabbig of focus. Only the contourset >> should be calculated. >> >> I can't find anything that describes this. Everybody wants the plot, >> not me. >> >> I would like to avoid hte workaround to ask for the currently active >> figure (if!! there is one at all), store the number, and later return >> focus. Is there no switch parameter (in pyplot or for contour at >> least) that turns plotting off? > > Hi Daniel, > > I'm not sure if this gets at what you're asking for, but if > you just want the contours plotted on a figure other than the > currently active one, grab a handle to some other axes and call > contour from the axes itself (the parameters are the same). > Here's what I mean: > > ----------- > f,ax =plt.subplots(1,1) #grab handles to figure and axes > # or, if you're using an older version of matplotlib, do: > # f=plt.figure();ax=plt.subplot(1,1,1) > > > f2,ax2 =plt.subplots(1,1) # "f" no longer active figure > ... > contourset = ax.contour(...) # draw to the old figure "f" > ----------- > > You can read more about the difference between using pyplot and > using the object-oriented api here: > > http://matplotlib.sourceforge.net/faq/usage_faq.html > > On the other hand, if you just want the contour to not show up, > you can pass it alpha=0.0 to make it completely transparent and > invisible (but it's still there) > > contourset = pyplot.contour(.., alpha=0.0) > # later call contourset.set_alpha(1.0) to make visible again > > best, > -- > Paul Ivanov > 314 address only used for lists, off-list direct email at: > http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 > I believe he would rather call the core function that contour uses to do the heavy lifting. This was something that one can do in matlab, btw. I don't have access to the source right now. What does contour call to perform this calculation? Ben Root
Hi Paul, > The reason you were getting that error is because unless you > specify otherwise, ax.bar will make the bottom of the bars at 0 - > which isn't an allowed date, hence the error. Change your bar > line to this (I also added align='center', but you can remove it > if you want): Aha, OK that makes sense. Thank you. I think the point #3 in my previous email about the "Ordinal must be >= 1" has all been about what is or isn't allowed as a proper date. So your example worked of course, but I am still not able to get my real code to plot a bar chart. If I tell you what the format of the data is, maybe you can help me. I would like to plot dates (on x axis) versus time intervals (on y). I have a list of dates and I have a two lists (self.data[0] and self.data[1]), one of the start times ("bots") and one of the stop times ("tops"). But when I go to plot it, and do this (based on your code...for now leaving out the round() step): bots = self.data[0] tops = self.data[1] bars = self.subplot.bar(self.final_dates, top-bot, bottom=bot, align='center') I get the error: TypeError: unsupported operand type(s) for -: 'list' and 'list' Because I am trying to subtract the "bots" list from the "tops" list. In the example code I gave, bot and times were not lists but were a 'numpy.ndarray' and a numpy.float64' object, respectfully, and I guess the - operand can be used on them. How can I structure my data such that this can work? (For some reason I have not had nearly this much confusion with plotting lines, just bars). Thanks for all the help, Che (CM)
Daniel Fulger, on 2011年01月27日 18:16, wrote: > Dear all, > > contourset = pyplot.contour(..) > > calculates the contourset but also grabs whatever figure is currently > active *somewhere* in the entire code > and whichever scope it was created. The contours are plotted into it. > > While I could possibly live with that, I would really like to > suppress any plotting and grabbig of focus. Only the contourset > should be calculated. > > I can't find anything that describes this. Everybody wants the plot, > not me. > > I would like to avoid hte workaround to ask for the currently active > figure (if!! there is one at all), store the number, and later return > focus. Is there no switch parameter (in pyplot or for contour at > least) that turns plotting off? Hi Daniel, I'm not sure if this gets at what you're asking for, but if you just want the contours plotted on a figure other than the currently active one, grab a handle to some other axes and call contour from the axes itself (the parameters are the same). Here's what I mean: ----------- f,ax =plt.subplots(1,1) #grab handles to figure and axes # or, if you're using an older version of matplotlib, do: # f=plt.figure();ax=plt.subplot(1,1,1) f2,ax2 =plt.subplots(1,1) # "f" no longer active figure ... contourset = ax.contour(...) # draw to the old figure "f" ----------- You can read more about the difference between using pyplot and using the object-oriented api here: http://matplotlib.sourceforge.net/faq/usage_faq.html On the other hand, if you just want the contour to not show up, you can pass it alpha=0.0 to make it completely transparent and invisible (but it's still there) contourset = pyplot.contour(.., alpha=0.0) # later call contourset.set_alpha(1.0) to make visible again best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
Dear all, contourset = pyplot.contour(..) calculates the contourset but also grabs whatever figure is currently active *somewhere* in the entire code and whichever scope it was created. The contours are plotted into it. While I could possibly live with that, I would really like to suppress any plotting and grabbig of focus. Only the contourset should be calculated. I can't find anything that describes this. Everybody wants the plot, not me. I would like to avoid hte workaround to ask for the currently active figure (if!! there is one at all), store the number, and later return focus. Is there no switch parameter (in pyplot or for contour at least) that turns plotting off? Regards Daniel
Hi all, I would like to contribute to a better readshapefile method, who should I contact / where should I commit ? First improvement and partial solution : * returning a tuple of linecollections per "record", with its name and other properties. Cheers, Thomas ps : example http://www.geophysique.be/2011/01/27/matplotlib-basemap-tutorial-07-shapefiles-unleached/ ********************** Thomas Lecocq Geologist Ph.D.Student (Seismology) Royal Observatory of Belgium **********************
Hi, Adding some extra work in the readshapefile method in your code allows you to play with the region names etc,... I've just made a new tutorial script to show this : http://www.geophysique.be/2011/01/27/matplotlib-basemap-tutorial-07-shapefiles-unleached/ Thom ********************** Thomas Lecocq Geologist Ph.D.Student (Seismology) Royal Observatory of Belgium ********************** Date: 2011年1月27日 17:59:03 +0800 From: eri...@gm... To: thl...@ms... CC: eri...@gm...; mat...@li... Subject: Re: [Matplotlib-users] How to draw a specific country by basemap? On 01/27/2011 01:38 AM, Thomas Lecocq wrote: Hi, An easy way is to use the data from http://www.gadm.org/ and to plot it with m.readshapefile() Thank you very much. The GDAM database is great. BTW, would you like to give some suggestions about how to color the map, i.e., highlight a specific region? Thanks, Eric HTH, Thom ********************** Thomas Lecocq Geologist Ph.D.Student (Seismology) Royal Observatory of Belgium ********************** Date: 2011年1月26日 16:03:27 +0800 From: eri...@gm... To: mat...@li... Subject: [Matplotlib-users] How to draw a specific country by basemap? Hi all, I'm using the Basemap module in matplotlib, it's great to draw a world map but for a specific country. Empirically, one can draw its own country by specifying the lats and longs like this example: http://matplotlib.sourceforge.net/basemap/doc/html/users/geography.html And you can use the method: drawcontries() to draw the country boundries, but all the countries are in the same colour. Does anyone know how to highlight a specific country? Thanks in advance. Eric -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+>++ L++ E++ W++ N+ o+>++ K+++ w !O M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+>* tv@ b++++ DI-- D G++ e++>+++@ h* r !y+ ------END GEEK CODE BLOCK------ ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a 49ドル USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+>++ L++ E++ W++ N+ o+>++ K+++ w !O M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+>* tv@ b++++ DI-- D G++ e++>+++@ h* r !y+ ------END GEEK CODE BLOCK------ ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a 49ドル USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Hi, that would do: data = m.readshapefile(r'borders\ita_adm1','itaborder',linewidth=0.5) italy = data[4] print dir(italy) italy.set_facecolors('red') italy.set_alpha(0.5) I think at some point you"ll meet the limitations of the method, you might need to use another shapefile-reading module ... Thom ********************** Thomas Lecocq Geologist Ph.D.Student (Seismology) Royal Observatory of Belgium ********************** Date: 2011年1月27日 17:59:03 +0800 From: eri...@gm... To: thl...@ms... CC: eri...@gm...; mat...@li... Subject: Re: [Matplotlib-users] How to draw a specific country by basemap? On 01/27/2011 01:38 AM, Thomas Lecocq wrote: Hi, An easy way is to use the data from http://www.gadm.org/ and to plot it with m.readshapefile() Thank you very much. The GDAM database is great. BTW, would you like to give some suggestions about how to color the map, i.e., highlight a specific region? Thanks, Eric HTH, Thom ********************** Thomas Lecocq Geologist Ph.D.Student (Seismology) Royal Observatory of Belgium ********************** Date: 2011年1月26日 16:03:27 +0800 From: eri...@gm... To: mat...@li... Subject: [Matplotlib-users] How to draw a specific country by basemap? Hi all, I'm using the Basemap module in matplotlib, it's great to draw a world map but for a specific country. Empirically, one can draw its own country by specifying the lats and longs like this example: http://matplotlib.sourceforge.net/basemap/doc/html/users/geography.html And you can use the method: drawcontries() to draw the country boundries, but all the countries are in the same colour. Does anyone know how to highlight a specific country? Thanks in advance. Eric -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+>++ L++ E++ W++ N+ o+>++ K+++ w !O M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+>* tv@ b++++ DI-- D G++ e++>+++@ h* r !y+ ------END GEEK CODE BLOCK------ ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a 49ドル USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+>++ L++ E++ W++ N+ o+>++ K+++ w !O M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+>* tv@ b++++ DI-- D G++ e++>+++@ h* r !y+ ------END GEEK CODE BLOCK------
On 01/27/2011 01:38 AM, Thomas Lecocq wrote: > Hi, > > An easy way is to use the data from http://www.gadm.org/ and to plot > it with m.readshapefile() Thank you very much. The GDAM database is great. BTW, would you like to give some suggestions about how to color the map, i.e., highlight a specific region? Thanks, Eric > > HTH, > > Thom > > ********************** > Thomas Lecocq > Geologist > Ph.D.Student (Seismology) > Royal Observatory of Belgium > ********************** > > > > ------------------------------------------------------------------------ > Date: 2011年1月26日 16:03:27 +0800 > From: eri...@gm... > To: mat...@li... > Subject: [Matplotlib-users] How to draw a specific country by basemap? > > Hi all, > > I'm using the Basemap module in matplotlib, it's great to draw a world > map but for a specific country. Empirically, one can draw its own > country by specifying the lats and longs like this example: > > http://matplotlib.sourceforge.net/basemap/doc/html/users/geography.html > > And you can use the method: drawcontries() to draw the country > boundries, but all the countries are in the same colour. Does anyone > know how to highlight a specific country? Thanks in advance. > > Eric > -- > -----BEGIN GEEK CODE BLOCK----- > Version: 3.1 > GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+>++ L++ E++ W++ N+ o+>++ K+++ w !O > M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+>* tv@ b++++ DI-- D G++ e++>+++@ h* > r !y+ > ------END GEEK CODE BLOCK------ > > ------------------------------------------------------------------------------ > Special Offer-- Download ArcSight Logger for FREE (a 49ドル USD value)! > Finally, a world-class log management solution at an even better > price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer > expires February 28th, so secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsight-sfd2d > _______________________________________________ Matplotlib-users > mailing list Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+>++ L++ E++ W++ N+ o+>++ K+++ w !O M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+>* tv@ b++++ DI-- D G++ e++>+++@ h* r !y+ ------END GEEK CODE BLOCK------
C M, on 2011年01月27日 02:03, wrote: > > 3) I am getting just hammered with the following error *a lot* in date > > plotting lately: > > > > ValueError: ordinal must be >= 1 > > > OK, I made up a small runnable sample to show this with bar(). (Using > code that someone else wrote[1]). This code runs when using > plot_date(), but if you comment that out and comment in the ax.bar() > line, it will give this ValueError. > > > import matplotlib.pyplot as plt > import matplotlib as mpl > import numpy as np > import datetime as dt > > # Make a series of events 1 day apart > x = mpl.dates.drange(dt.datetime(2009,10,1), > dt.datetime(2010,1,15), > dt.timedelta(days=1)) > # Vary the datetimes so that they occur at random times > # Remember, 1.0 is equivalent to 1 day in this case... > x += np.random.random(x.size) > > # We can extract the time by using a modulo 1, and adding an arbitrary base date > times = x % 1 + int(x[0]) # (The int is so the y-axis starts at midnight...) > > # I'm just plotting points here, but you could just as easily use a bar. > fig = plt.figure() > ax = fig.add_subplot(111) > > #comment out: > ax.plot_date(x, times, 'ro') > Hi C. M., The reason you were getting that error is because unless you specify otherwise, ax.bar will make the bottom of the bars at 0 - which isn't an allowed date, hence the error. Change your bar line to this (I also added align='center', but you can remove it if you want): > #comment in bot = times.min().round() ax.bar(x, times-bot, bottom=bot, align='center') > > ax.yaxis_date() > fig.autofmt_xdate() > > plt.show() best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
> 3) I am getting just hammered with the following error *a lot* in date > plotting lately: > > ValueError: ordinal must be >= 1 OK, I made up a small runnable sample to show this with bar(). (Using code that someone else wrote[1]). This code runs when using plot_date(), but if you comment that out and comment in the ax.bar() line, it will give this ValueError. import matplotlib.pyplot as plt import matplotlib as mpl import numpy as np import datetime as dt # Make a series of events 1 day apart x = mpl.dates.drange(dt.datetime(2009,10,1), dt.datetime(2010,1,15), dt.timedelta(days=1)) # Vary the datetimes so that they occur at random times # Remember, 1.0 is equivalent to 1 day in this case... x += np.random.random(x.size) # We can extract the time by using a modulo 1, and adding an arbitrary base date times = x % 1 + int(x[0]) # (The int is so the y-axis starts at midnight...) # I'm just plotting points here, but you could just as easily use a bar. fig = plt.figure() ax = fig.add_subplot(111) #comment out: ax.plot_date(x, times, 'ro') #comment in #ax.bar(x, times) ax.yaxis_date() fig.autofmt_xdate() plt.show() [1]http://stackoverflow.com/questions/4790265/plot-time-of-day-vs-date-in-matplotlib
On Wed, Jan 26, 2011 at 9:16 PM, Jae-Joon Lee <lee...@gm...> wrote: > On Thu, Jan 27, 2011 at 10:07 AM, C M <cmp...@gm...> wrote: >> I know the 2nd problem is that a dictionary cannot have a mutable >> object like a list as a key. But previously, as I said, I was able to >> call line, (with the comma) and it would work. In fact, line, with a >> comma gives this type: >> > > If you just want a hashable object, can you just cast it to a tuple? > > > bars = self.subplot.bar(fake_data, fake_data ) > bars_tuple = tuple(bars) > > bars_tuple can be used as a dictionary key. Yes, that can work, thanks, but I am still stuck without a bar chart for other reasons (see point #3 below), and I am still confused. I have some questions that if answered can hopefully help me get clearer: 1) What does the comma do exactly? If I put this: "line," I create a matplotlib line object, whereas if I put just "line" I create a list. Does this mean that plot() in mpl returns a tuple that contains one element, which is a mpl line object? (If so, why doesn't it just return the line object itself?) 2) Why does line, followed by plot() return a mpl line object but bars, followed by bar() not return some kind of matplotlib object (like a line)? Why does it instead give the "ValueError: Too many values to unpack" error? 3) I am getting just hammered with the following error *a lot* in date plotting lately: ValueError: ordinal must be >= 1 And I can't figure out what sorts of mistakes or situations are triggering it. More of the traceback above that error is at the end of this message. Does someone know when this error will be thrown when using dates so I can at least know what to check for in my data? Thanks, Che ------ more of Traceback: for ylabel_i in self.subplot.get_yticklabels(): File "C:\Python25\lib\site-packages\matplotlib\axes.py", line 2646, in get_yticklabels self.yaxis.get_ticklabels(minor=minor)) File "C:\Python25\lib\site-packages\matplotlib\axis.py", line 1087, in get_ticklabels return self.get_majorticklabels() File "C:\Python25\lib\site-packages\matplotlib\axis.py", line 1071, in get_majorticklabels ticks = self.get_major_ticks() File "C:\Python25\lib\site-packages\matplotlib\axis.py", line 1169, in get_major_ticks numticks = len(self.get_major_locator()()) File "C:\Python25\lib\site-packages\matplotlib\dates.py", line 743, in __call__ self.refresh() File "C:\Python25\lib\site-packages\matplotlib\dates.py", line 752, in refresh dmin, dmax = self.viewlim_to_dt() File "C:\Python25\lib\site-packages\matplotlib\dates.py", line 524, in viewlim_to_dt return num2date(vmin, self.tz), num2date(vmax, self.tz) File "C:\Python25\lib\site-packages\matplotlib\dates.py", line 289, in num2date if not cbook.iterable(x): return _from_ordinalf(x, tz) File "C:\Python25\lib\site-packages\matplotlib\dates.py", line 203, in _from_ordinalf dt = datetime.datetime.fromordinal(ix) ValueError: ordinal must be >= 1
The problem is that if no display is available, the error gets raised on the point where I try to create a new figure, long before getting to show(), so I can't do anything at all. Here's what it looks like when I log in without a display available: >>> import matplotlib.pyplot as plt >>> plt.figure() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/Python/Versions/2.6.5/lib/python2.6/site-packages/matplotlib/pyplot.py", line 270, in figure **kwargs) File "/usr/local/Python/Versions/2.6.5/lib/python2.6/site-packages/matplotlib/backends/backend_tkagg.py", line 83, in new_figure_manager window = Tk.Tk() File "/usr/local/Python/Versions/2.6.5/lib/python2.6/lib-tk/Tkinter.py", line 1643, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: no display name and no $DISPLAY environment variable I can do this, which is widely recommended: >>> import matplotlib >>> matplotlib.use('Agg') >>> import matplotlib.pyplot as plt >>> fig=plt.figure() >>> fig.save_fig('test.png') But as far as I can tell from searching, once you do this, there is no way to display to the screen. Unless there is a very clever trick that I don't know about... which I am asking for here... :-) On Jan 26, 2011, at 11:16 PM, Benjamin Root wrote: > On Wednesday, January 26, 2011, David Perlman <dpe...@wi...> wrote: >> I'm trying to make a simple utility for doing a quick check of some data (electrophysiology recordings from our fMRI scanner lab). I want it to be foolproof as much as possible, so I was trying to figure out how to write a script that would try to plot to the display, then if that didn't work, to save it to a file instead (preferably as pdf, but I could live with png if that was the only option.) >> >> I've been searching the documentation and code examples for a while, and all I can find seems to suggest that the choice of display vs. file is predetermined at the very beginning by the choice of backend. I suppose that would mean I'd have to put the whole thing inside a try block, then if that didn't work, start over from scratch with a different backend and build the plot again. I was hoping to find a way to build the plot, then just try to "show" it or something like that, and if that failed, then save it instead. But so far I have not been able to figure out such a thing. So I would appreciate any help! Thanks very much! >> >> > > You can always put the show call in a try block and do a savefig if > the show fails. I don't know where you get the idea that you have to > do one or the other... > > Unless you are talking about the issue where the closing of a figure > window would cause you to lose the figure data? In which case, you > should be fine catching the show and doing the savefigg because the > close event never occurred. However, you might get messy this way with > a blank figure window... > > To be "foolproof" I would just always save first and then attempt to > show. If the show was successful, you can delete the saved figure. > > Sorry for the rambling, but those are my thoughts on it. > > Ben Root -- -dave---------------------------------------------------------------- "Pseudo-colored pictures of a person's brain lighting up are undoubtedly more persuasive than a pattern of squiggles produced by a polygraph. That could be a big problem if the goal is to get to the truth." -Dr. Steven Hyman, Harvard
On Wednesday, January 26, 2011, David Perlman <dpe...@wi...> wrote: > I'm trying to make a simple utility for doing a quick check of some data (electrophysiology recordings from our fMRI scanner lab). I want it to be foolproof as much as possible, so I was trying to figure out how to write a script that would try to plot to the display, then if that didn't work, to save it to a file instead (preferably as pdf, but I could live with png if that was the only option.) > > I've been searching the documentation and code examples for a while, and all I can find seems to suggest that the choice of display vs. file is predetermined at the very beginning by the choice of backend. I suppose that would mean I'd have to put the whole thing inside a try block, then if that didn't work, start over from scratch with a different backend and build the plot again. I was hoping to find a way to build the plot, then just try to "show" it or something like that, and if that failed, then save it instead. But so far I have not been able to figure out such a thing. So I would appreciate any help! Thanks very much! > > You can always put the show call in a try block and do a savefig if the show fails. I don't know where you get the idea that you have to do one or the other... Unless you are talking about the issue where the closing of a figure window would cause you to lose the figure data? In which case, you should be fine catching the show and doing the savefigg because the close event never occurred. However, you might get messy this way with a blank figure window... To be "foolproof" I would just always save first and then attempt to show. If the show was successful, you can delete the saved figure. Sorry for the rambling, but those are my thoughts on it. Ben Root
Forgive me if this is an old question, but I just loaded mplot3d and was attempting to work through a couple of the examples on the Matplotlib website. The problem is that whenever I try to make a call to a function that requires an argument of projection='3d' (such as: ax = fig.add_subplot(111, projection='3d')), Python gives me the following error: Traceback (most recent call last): File "<pyshell#12>", line 1, in <module> ax = fig.add_subplot(111, projection='3d') File "C:\Python26\lib\site-packages\matplotlib\figure.py", line 677, in add_subplot projection_class = get_projection_class(projection) File "C:\Python26\lib\site-packages\matplotlib\projections\__init__.py", line 61, in get_projection_class raise ValueError("Unknown projection '%s'" % projection) ValueError: Unknown projection '3d' Running help on fig.add_subplot does not show '3d' as a valid projection type for this function. What's going on, and how do I fix it? I'm running Python 2.6.6 on Windows 7. Thanks in advance. /s/ Pat
I'm trying to make a simple utility for doing a quick check of some data (electrophysiology recordings from our fMRI scanner lab). I want it to be foolproof as much as possible, so I was trying to figure out how to write a script that would try to plot to the display, then if that didn't work, to save it to a file instead (preferably as pdf, but I could live with png if that was the only option.) I've been searching the documentation and code examples for a while, and all I can find seems to suggest that the choice of display vs. file is predetermined at the very beginning by the choice of backend. I suppose that would mean I'd have to put the whole thing inside a try block, then if that didn't work, start over from scratch with a different backend and build the plot again. I was hoping to find a way to build the plot, then just try to "show" it or something like that, and if that failed, then save it instead. But so far I have not been able to figure out such a thing. So I would appreciate any help! Thanks very much! -- -dave---------------------------------------------------------------- "Pseudo-colored pictures of a person's brain lighting up are undoubtedly more persuasive than a pattern of squiggles produced by a polygraph. That could be a big problem if the goal is to get to the truth." -Dr. Steven Hyman, Harvard
On Thu, Jan 27, 2011 at 10:07 AM, C M <cmp...@gm...> wrote: > I know the 2nd problem is that a dictionary cannot have a mutable > object like a list as a key. But previously, as I said, I was able to > call line, (with the comma) and it would work. In fact, line, with a > comma gives this type: > If you just want a hashable object, can you just cast it to a tuple? bars = self.subplot.bar(fake_data, fake_data ) bars_tuple = tuple(bars) bars_tuple can be used as a dictionary key. Regards, -JJ
Hi Ben: That's encouraging! I want to be able plot up to N data points (the points are in an ordered sequence) on a canvas and then zoom into the plot region enclosed within a subset sequence (e.g., T1 to T2 data points, 0 <= T1 < T2 <=N) by putting two cursors - one on T1 and the other one on T2. regards, Soumyaroop On Wed, Jan 26, 2011 at 6:44 PM, Benjamin Root <ben...@ou...> wrote: > On Wednesday, January 26, 2011, Soumyaroop Roy <sou...@gm...> wrote: >> Hi there: >> >> Does matplotlib have provide any feature to allow zooming into plot >> regions like a waveform viewer does? >> >> regards, >> Soumyaroop >> > > Mpl offers full control of the plot display. Maybe if you offer an > example of what you are looking for, we might be able to point you to > a way to do what you want? > > Ben Root >
> Just a thought, are you trying out the new legend code? I don't know if I am or not. But these problems are prior to any code regarding the legend. > Could you do a print of the type for bars? When I write it as just bars without the comma it is: bars type = <type 'list'> If I write it with the comma ( bars,) then it won't even run because of the ValueError. I know the 2nd problem is that a dictionary cannot have a mutable object like a list as a key. But previously, as I said, I was able to call line, (with the comma) and it would work. In fact, line, with a comma gives this type: line type = <class 'matplotlib.lines.Line2D'> Thanks, Che