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) |
|
|
|
|
|
etc for producing images at various scales) Reply-To: In-Reply-To: <20110121232036.GA26739@ykcyc> X-PGP-Key: http://pirsquared.org/PaulIvanov0F3E28F7.asc Paul Ivanov, on 2011年01月21日 15:20, wrote: > I'm almost certain that one *can* write a function to do this > pro grammatically (without having to hand tweak anything), by > looking at say, the .get_window_extent() but I haven't found the > time to scratch that itch, yet. > > If someone wants to beat me to it, here's the sort of thing that > you can do: > > def show_labels_by_shrinking(ax): > " adjust subplot parameters to fit the yaxis label" > f = ax.figure > textwidth = ax.yaxis.get_label().get_window_extent().width > labelwidth = max([lab.get_window_extent().width for lab in ax.get_yticklabels()]) > plt.subplots_adjust(left=(textwidth+labelwidth+3*ax.yaxis.labelpad)/f.get_window_extent().width) > # the 3 *ax.yaxis.labelpad is just a fudge factor for now, need > # to look into the sourcecode to figure out what the > # appropriate placement is normally, to know how to adjust > # properly > > > ax.set_ylabel('foo') > show_labels_by_shrinking(ax) > ax.set_ylabel("a\nmulti\nline\nexample") > show_labels_by_shrinking(ax) I should add that along with doing a similar thing for the xaxis, this would need to be extended for the multiple subplot case, to also adjust the wspace and hspace parameters accordingly. this is important functionality currently missing from matplotlib out-of-the-box at the moment, so I'll try my crack at it this out this weekend. CCing the devel list in case someone has more opinions. best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
Daryl Herzmann, on 2011年01月21日 16:41, wrote: > On Fri, Jan 21, 2011 at 4:15 PM, Paul Ivanov <piv...@gm...> wrote: > > > I guess I'm not sure what you meant by the fonts looking 'nasty', > > so if font.size doesn't address your issue, could you post a > > small example that does the wrong thing, along with the type of > > output you were hoping to get. > > Thanks for the responses and sorry to not be clear. Here is an example script: > > import matplotlib.pyplot as plt > > fig = plt.figure(figsize=(8,8)) > > ax = fig.add_subplot(111) > > ax.plot( [0,100], [0,100] ) > ax.set_xlabel("Temperature after the sun goes down $^{\circ}F$") > ax.set_ylabel("Temperature when the sun goes up $^{\circ}F$") > ax.set_title("My Fancy Plot!!!") > > fig.savefig('test.png', dpi=(40)) > > > with 3 different outputs. First two numbers are figsize settings and > last is DPI. > > In my perfect world, I would like to simple to this at the end of my script: > > fig.savefig('thumbnail.png', .....) > fig.savefig('fullsize.png', ......) > > and get two clean looking images. If I have to rerun the script with > different options to get a thumbnail and then a fullsize, that is okay > too. I just can't figure out what all needs to be tweeked / how to do > it.. Daryl, ok, much clearer now - what you want is for your text to not be cut-off the way it is in the 8x8 80dpi plot? In other words, there's not enough space left in the figure for the axis labels to be completely displayed. At the moment, I don't think there's a simple way of doing it, and the quick way I find myself doing is by adjusting the subplot parameters using: plt.subplots_adjust(left=..., bottom=...) I'm almost certain that one *can* write a function to do this pro grammatically (without having to hand tweak anything), by looking at say, the .get_window_extent() but I haven't found the time to scratch that itch, yet. If someone wants to beat me to it, here's the sort of thing that you can do: def show_labels_by_shrinking(ax): " adjust subplot parameters to fit the yaxis label" f = ax.figure textwidth = ax.yaxis.get_label().get_window_extent().width labelwidth = max([lab.get_window_extent().width for lab in ax.get_yticklabels()]) plt.subplots_adjust(left=(textwidth+labelwidth+3*ax.yaxis.labelpad)/f.get_window_extent().width) # the 3 *ax.yaxis.labelpad is just a fudge factor for now, need # to look into the sourcecode to figure out what the # appropriate placement is normally, to know how to adjust # properly ax.set_ylabel('foo') show_labels_by_shrinking(ax) ax.set_ylabel("a\nmulti\nline\nexample") show_labels_by_shrinking(ax) best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
On Fri, Jan 21, 2011 at 4:15 PM, Paul Ivanov <piv...@gm...> wrote: > I guess I'm not sure what you meant by the fonts looking 'nasty', > so if font.size doesn't address your issue, could you post a > small example that does the wrong thing, along with the type of > output you were hoping to get. Thanks for the responses and sorry to not be clear. Here is an example script: import matplotlib.pyplot as plt fig = plt.figure(figsize=(8,8)) ax = fig.add_subplot(111) ax.plot( [0,100], [0,100] ) ax.set_xlabel("Temperature after the sun goes down $^{\circ}F$") ax.set_ylabel("Temperature when the sun goes up $^{\circ}F$") ax.set_title("My Fancy Plot!!!") fig.savefig('test.png', dpi=(40)) with 3 different outputs. First two numbers are figsize settings and last is DPI. In my perfect world, I would like to simple to this at the end of my script: fig.savefig('thumbnail.png', .....) fig.savefig('fullsize.png', ......) and get two clean looking images. If I have to rerun the script with different options to get a thumbnail and then a fullsize, that is okay too. I just can't figure out what all needs to be tweeked / how to do it.. thanks, daryl
On 01/21/2011 11:42 AM, Daryl Herzmann wrote: > Greetings matplotlib users, > > Firstly, thank you so much for a great python plotting library. I use > it daily and find the library very intuitive :) My question deals > with generating raster images at multiple scales without heavy code > modification. My work flow is to generate two versions of the same > plot, one thumbnail (~ 320x320) and then one 'full size' around (~ > 800x800) in PNG format for the web. > > My current methodology is to generate a postscript file and then send > it through ImageMagick's convert to generate the two different sized > images. I find that this works 'good enough for me', but I often run > into problems when I have transparency in the plot and that > information is lost in the translation of formats... I also get > fairly bulky file sizes, but that is probably my fault for not using > the proper convert flags, anyway... > > I have tried messing around with the dpi and figsize settings to the > initial: fig = plt.figure() and fig.savefig() , but I can't seem to > get similiar quality to my hacky method outlined above. Many times, > the fonts look nasty :) I don't know what would be causing that; we routinely generate png files directly from mpl for a thumbnail and a full-size figure, simply changing the dpi kwarg in savefig, and the results have been satisfactory. Can you post a simple script and pair of png files illustrating the problem? (Here is a page of such thumbnails; clicking on one brings up the full-size version. http://currents.soest.hawaii.edu/uhdas_fromships/kilomoana/figs/) Eric > > Any tips or tricks to make this happen? Thanks again and I sincerely > apologize if I missed a FAQ item , etc on this... > > daryl > > ------------------------------------------------------------------------------ > 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
Daryl Herzmann, on 2011年01月21日 15:42, wrote: > Greetings matplotlib users, > > Firstly, thank you so much for a great python plotting library. I use > it daily and find the library very intuitive :) My question deals > with generating raster images at multiple scales without heavy code > modification. My work flow is to generate two versions of the same > plot, one thumbnail (~ 320x320) and then one 'full size' around (~ > 800x800) in PNG format for the web. > > My current methodology is to generate a postscript file and then send > it through ImageMagick's convert to generate the two different sized > images. I find that this works 'good enough for me', but I often run > into problems when I have transparency in the plot and that > information is lost in the translation of formats... I also get > fairly bulky file sizes, but that is probably my fault for not using > the proper convert flags, anyway... > > I have tried messing around with the dpi and figsize settings to the > initial: fig = plt.figure() and fig.savefig() , but I can't seem to > get similiar quality to my hacky method outlined above. Many times, > the fonts look nasty :) > > Any tips or tricks to make this happen? Thanks again and I sincerely > apologize if I missed a FAQ item , etc on this... Hi Daryl, I'm not sure I understand what it is that you want, but if the issue is related to scaling fonts depending on output figure size and/or dpi - have you tried playing around with the 'font.size' rcParam, and defining your font sized using 'xx-small', 'x-large', etc, instead of specifying a point size directly? From .matplotlibrc: # note that font.size controls default text sizes. To configure # special text sizes tick labels, axes, labels, title, etc, see the rc # settings for axes and ticks. Special text sizes can be defined # relative to font.size, using the following values: xx-small, x-small, # small, medium, large, x-large, xx-large, larger, or smaller #font.size : 12.0 I guess I'm not sure what you meant by the fonts looking 'nasty', so if font.size doesn't address your issue, could you post a small example that does the wrong thing, along with the type of output you were hoping to get. My feeling is that there shouldn't be a need to use ImageMagick - but depending on the size and dpi of your desired figures, is the problem that the text is not being antialiased? best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
Greetings matplotlib users, Firstly, thank you so much for a great python plotting library. I use it daily and find the library very intuitive :) My question deals with generating raster images at multiple scales without heavy code modification. My work flow is to generate two versions of the same plot, one thumbnail (~ 320x320) and then one 'full size' around (~ 800x800) in PNG format for the web. My current methodology is to generate a postscript file and then send it through ImageMagick's convert to generate the two different sized images. I find that this works 'good enough for me', but I often run into problems when I have transparency in the plot and that information is lost in the translation of formats... I also get fairly bulky file sizes, but that is probably my fault for not using the proper convert flags, anyway... I have tried messing around with the dpi and figsize settings to the initial: fig = plt.figure() and fig.savefig() , but I can't seem to get similiar quality to my hacky method outlined above. Many times, the fonts look nasty :) Any tips or tricks to make this happen? Thanks again and I sincerely apologize if I missed a FAQ item , etc on this... daryl
Francesco Montesano, on 2011年01月21日 15:44, wrote: > Dear All, > > I am using contour plot and I am drawing different contours with > different colors and linestyles and I would like to have a legend with > a caption for each contour function used. > Here you can see an example of what I would like to do > > >> #create the 2D histogram and the x and y axis > >> x, y = np.random.normal(0, 0.5, 1000), np.random.normal(0, 1, 1000) > >> h, xe,ye = np.histogram2d(x,y, bins=25) > >> xe, ye = (xe[1:]+xe[:-1])/2, (ye[1:]+ye[:-1])/2 > >> > >> lines,text = [], [] # initialise lists > >> > >> #contour plots > >> lines.append(plt.contour(xe,ye,h, levels=[10,9], linestyles="-", colors="k")) > >> text.append("level=10, 9") > >> > >> lines.append(plt.contour(xe,ye,h, levels=[5,4], linestyles="--", colors="r")) > >> text.append("level=5, 4") > >> > >> plt.legend(lines, text) > > Everything goes well untill I plot the legend. At the end of the mail > I report the error that I get. > Anyway, if I do > >> plt.legend(lines) > I don't get any errors but it's quite useless, since the text of the > legend is just like: > <matplotlib.contour.ContourSet instance at 0x6bedc20> > as you can see from the attached figure. > > > I've the feeling that the problem is that "contour" gives back a > "matplotlib.contour.ContourSet instance", while the functions like > "plot" gives back a "<matplotlib.lines.Line2D object". > > Does anyone knows how to do what I want? > Hi Francesco, here's one way of getting what you want, instead of calling legend on your 'lines' variable as you had it, do this: actual_lines = [cs.collections[0] for cs in lines] plt.legend(actual_lines, text) As you note, the call to plt.countour does not return lines, it returns contour sets (which is why I called the variable 'cs' in my example). Poking around in ipython, I saw that each contour set has a collections attribute which holds the actual lines. hope that helps, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
Homebrew is a newish package management system that is Git-based: http://mxcl.github.com/homebrew/ ................................................................................... Uri Laserson Graduate Student, Biomedical Engineering Harvard-MIT Division of Health Sciences and Technology M +1 917 742 8019 las...@mi... On Fri, Jan 21, 2011 at 12:27, Friedrich Romstedt < fri...@gm...> wrote: > 2011年1月20日 Uri Laserson <las...@mi...>: > > Hi all, > > I recently reinstalled MPL from scratch on top of python2.7 that I built > > from scratch using homebrew on OS X Snow Leopard. Since then, I have > been > > getting the following types of warnings whenever I plot something: > > > /Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/font_manager.py:1242: > > UserWarning: findfont: Font family ['sans-serif'] not found. Falling back > to > > Bitstream Vera Sans > > (prop.get_family(), self.defaultFamily[fontext])) > > I'm not sure what you mean by "using homebrew" (is this a software > package or do you mean you compiled it yourself), but have you > specified anything special in your matplotlibrc? > > Friedrich >
Problem solved. Thanks! Uri ................................................................................... Uri Laserson Graduate Student, Biomedical Engineering Harvard-MIT Division of Health Sciences and Technology M +1 917 742 8019 las...@mi... On Fri, Jan 21, 2011 at 12:44, todd rme <tod...@gm...> wrote: > On Thu, Jan 20, 2011 at 2:09 PM, Uri Laserson <las...@mi...> wrote: > > Hi all, > > I recently reinstalled MPL from scratch on top of python2.7 that I built > > from scratch using homebrew on OS X Snow Leopard. Since then, I have > been > > getting the following types of warnings whenever I plot something: > > > /Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/font_manager.py:1242: > > UserWarning: findfont: Font family ['sans-serif'] not found. Falling back > to > > Bitstream Vera Sans > > (prop.get_family(), self.defaultFamily[fontext])) > > Do I need to specify some configuration parameter to point somewhere that > > the installer couldn't find? > > Thanks! > > Uri > > I had the same problem when I upgraded from python 2.6 to 2.7. For > me, the issue turned out to be with my matplotlib font cache, which > was stored in my matplotlib config directory. On linux it is in > .matplotlib directory in the home directory, I am not sure if this is > where it is on a mac. I deleted the fontList.cache file and the > tex.cache directory stored there, and that fixed the problem. I am > not sure you need to delete both of these, but since they were just > caches I went ahead and did so. > > -Todd > > > ------------------------------------------------------------------------------ > 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 >
2011年1月21日 todd rme <tod...@gm...>: > I had the same problem when I upgraded from python 2.6 to 2.7. For > me, the issue turned out to be with my matplotlib font cache, which > was stored in my matplotlib config directory. On linux it is in > .matplotlib directory in the home directory, I am not sure if this is > where it is on a mac. It's ~/.matplotlib/fontList.cache on Mac too. > I deleted the fontList.cache file and the > tex.cache directory stored there, and that fixed the problem. I am > not sure you need to delete both of these, but since they were just > caches I went ahead and did so. Friedrich
Bala subramanian, on 2011年01月21日 12:17, wrote: > Daniel, > Did you try saving the figure with same dpi ?. Try the following. > > plt.savefig('name',dpi=300) > > On Fri, Jan 21, 2011 at 9:08 AM, Daniel Mader < > dan...@go...> wrote: > > > Hi, > > > > I need to create a huge range of plots with need to fit into a report > > (OpenOffice or Word). In order to save the work of manual resizing them when > > dragged and dropped, I wanted to preset a correct figure size with a nice > > resolution: > > > > pylab.rcParams['figure.figsize'] = 5,4 > > pylab.rcParams['figure.dpi'] = 300 > > > > Now, the created figure has a size of 500x400 pixels, and when I import it > > into a word processor, its dimensions are reported as 12.7x10.16cm2, which > > matches the figsize definition. Yet, the resulting images are pretty much > > blurred... > > > > How can I increase the resolution, or what am I doing wrong? Hi Daniel, As Bala alluded - there's a difference between display dpi and the file saving dpi. Your change to rcParams only affected the displayed resolution, not the resolution of saved files. Quoting from .matplotlibrc # the default savefig params can be different from the display params # Eg, you may want a higher resolution, or to make the figure # background white #savefig.dpi : 100 # figure dots per inch So try playing around with that parameter (which is what you're doing if you call plt.savefig('name', dpi=300) best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
On Thu, Jan 20, 2011 at 2:09 PM, Uri Laserson <las...@mi...> wrote: > Hi all, > I recently reinstalled MPL from scratch on top of python2.7 that I built > from scratch using homebrew on OS X Snow Leopard. Since then, I have been > getting the following types of warnings whenever I plot something: > /Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/font_manager.py:1242: > UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to > Bitstream Vera Sans > (prop.get_family(), self.defaultFamily[fontext])) > Do I need to specify some configuration parameter to point somewhere that > the installer couldn't find? > Thanks! > Uri I had the same problem when I upgraded from python 2.6 to 2.7. For me, the issue turned out to be with my matplotlib font cache, which was stored in my matplotlib config directory. On linux it is in .matplotlib directory in the home directory, I am not sure if this is where it is on a mac. I deleted the fontList.cache file and the tex.cache directory stored there, and that fixed the problem. I am not sure you need to delete both of these, but since they were just caches I went ahead and did so. -Todd
2011年1月20日 Uri Laserson <las...@mi...>: > Hi all, > I recently reinstalled MPL from scratch on top of python2.7 that I built > from scratch using homebrew on OS X Snow Leopard. Since then, I have been > getting the following types of warnings whenever I plot something: > /Users/laserson/matplotlib/lib/python2.7/site-packages/matplotlib/font_manager.py:1242: > UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to > Bitstream Vera Sans > (prop.get_family(), self.defaultFamily[fontext])) I'm not sure what you mean by "using homebrew" (is this a software package or do you mean you compiled it yourself), but have you specified anything special in your matplotlibrc? Friedrich
Dear All, I am using contour plot and I am drawing different contours with different colors and linestyles and I would like to have a legend with a caption for each contour function used. Here you can see an example of what I would like to do >> #create the 2D histogram and the x and y axis >> x, y = np.random.normal(0, 0.5, 1000), np.random.normal(0, 1, 1000) >> h, xe,ye = np.histogram2d(x,y, bins=25) >> xe, ye = (xe[1:]+xe[:-1])/2, (ye[1:]+ye[:-1])/2 >> >> lines,text = [], [] # initialise lists >> >> #contour plots >> lines.append(plt.contour(xe,ye,h, levels=[10,9], linestyles="-", colors="k")) >> text.append("level=10, 9") >> >> lines.append(plt.contour(xe,ye,h, levels=[5,4], linestyles="--", colors="r")) >> text.append("level=5, 4") >> >> plt.legend(lines, text) Everything goes well untill I plot the legend. At the end of the mail I report the error that I get. Anyway, if I do >> plt.legend(lines) I don't get any errors but it's quite useless, since the text of the legend is just like: <matplotlib.contour.ContourSet instance at 0x6bedc20> as you can see from the attached figure. I've the feeling that the problem is that "contour" gives back a "matplotlib.contour.ContourSet instance", while the functions like "plot" gives back a "<matplotlib.lines.Line2D object". Does anyone knows how to do what I want? Thanks in advance Francesco ps: Error message follow -------------------------- /usr/lib/pymodules/python2.6/matplotlib/pyplot.pyc in legend(*args, **kwargs) 2435 # changes will be lost 2436 def legend(*args, **kwargs): -> 2437 ret = gca().legend(*args, **kwargs) 2438 draw_if_interactive() 2439 return ret /usr/lib/pymodules/python2.6/matplotlib/axes.pyc in legend(self, *args, **kwargs) 4042 4043 handles = cbook.flatten(handles) -> 4044 self.legend_ = mlegend.Legend(self, handles, labels, **kwargs) 4045 return self.legend_ 4046 /usr/lib/pymodules/python2.6/matplotlib/legend.pyc in __init__(self, parent, handles, labels, loc, numpoints, markerscale, scatterpoints, scatteryoffsets, prop, pad, labelsep, handlelen, handletextsep, axespad, borderpad, labelspacing, handlelength, handletextpad, borderaxespad, columnspacing, ncol, mode, fancybox, shadow, title, bbox_to_anchor, bbox_transform) 302 303 # init with null renderer --> 304 self._init_legend_box(handles, labels) 305 306 self.set_title(title) /usr/lib/pymodules/python2.6/matplotlib/legend.pyc in _init_legend_box(self, handles, labels) 580 581 handle = handle_list[-1] --> 582 handlebox.add_artist(handle) 583 if hasattr(handle, "_legmarker"): 584 handlebox.add_artist(handle._legmarker) /usr/lib/pymodules/python2.6/matplotlib/offsetbox.pyc in add_artist(self, a) 473 'Add any :class:`~matplotlib.artist.Artist` to the container box' 474 self._children.append(a) --> 475 a.set_transform(self.get_transform()) 476 477 AttributeError: 'NoneType' object has no attribute 'set_transform'
Daniel, Did you try saving the figure with same dpi ?. Try the following. plt.savefig('name',dpi=300) On Fri, Jan 21, 2011 at 9:08 AM, Daniel Mader < dan...@go...> wrote: > Hi, > > I need to create a huge range of plots with need to fit into a report > (OpenOffice or Word). In order to save the work of manual resizing them when > dragged and dropped, I wanted to preset a correct figure size with a nice > resolution: > > pylab.rcParams['figure.figsize'] = 5,4 > pylab.rcParams['figure.dpi'] = 300 > > Now, the created figure has a size of 500x400 pixels, and when I import it > into a word processor, its dimensions are reported as 12.7x10.16cm2, which > matches the figsize definition. Yet, the resulting images are pretty much > blurred... > > How can I increase the resolution, or what am I doing wrong? > Thanks in advance, > Daniel > > > ------------------------------------------------------------------------------ > 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, I need to create a huge range of plots with need to fit into a report (OpenOffice or Word). In order to save the work of manual resizing them when dragged and dropped, I wanted to preset a correct figure size with a nice resolution: pylab.rcParams['figure.figsize'] = 5,4 pylab.rcParams['figure.dpi'] = 300 Now, the created figure has a size of 500x400 pixels, and when I import it into a word processor, its dimensions are reported as 12.7x10.16cm2, which matches the figsize definition. Yet, the resulting images are pretty much blurred... How can I increase the resolution, or what am I doing wrong? Thanks in advance, Daniel
Hi, I'm trying to install matplotlib from the svn source. I can compile the code and install it to my desired location but I cannot import it into python. I did: svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib matplotlib cd matplotlib python setup.py install --prefix=/home/glen/local I have numpy and scipy installed and working correctly using the above prefix and matplotlib compiles and installs the same way but when I issue "import matplotlib as mpl" nothing results. There is no error but also no library. >>> dir(mpl) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__'] >>> mpl.__path__ ['matplotlib'] >>> mpl.__file__ 'matplotlib/__init__.pyc' Where am I going wrong? Glen
On Thursday, January 20, 2011, Jeff Whitaker <js...@fa...> wrote: > On 1/20/11 2:31 PM, R. Mitra wrote: >> Hi >> I have a set of records with known lat long. I want to show the >> concentration of the records with a contour diagram on a world map in >> any projection. It cannot spill over to the oceans. I know I have to >> use basemap. Is there a quick recipe somewhere I can follow to give >> me a desired output. I have gone through earlier posts on this board >> but cannot find the right one. Any pointers would be very helpful. >> Many thanks. >> Best >> Mitra > > > Mitra: The basic procedure is this: > > 1) load you data into 2d numpy arrays (lats, lons, data). lats and lons > must be in degrees (not radians). > 2) create a Basemap instance (called "map") for the desired projection. > 3) calculate the map projection coordinates of your grid with x,y = > map(lons,lats) > 4) contour your data with the contourf method (map.contourf). > 5) draw coastlines with the coastlines method. > 6) draw lat/lon lines with the drawparallels and drawmeridians methods. > > There are many examples of this in the basemap examples directory. > > -Jeff > > ------------------------------------------------------------------------------ > 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 > In order to contour, you will need some sort z-value to contour. This means you need to bin your data. You could use numpy's hist2d, or (I prefer) matplotlib's hexbin(). I hope that helps! Ben Root
On 1/20/11 2:31 PM, R. Mitra wrote: > Hi > I have a set of records with known lat long. I want to show the > concentration of the records with a contour diagram on a world map in > any projection. It cannot spill over to the oceans. I know I have to > use basemap. Is there a quick recipe somewhere I can follow to give > me a desired output. I have gone through earlier posts on this board > but cannot find the right one. Any pointers would be very helpful. > Many thanks. > Best > Mitra Mitra: The basic procedure is this: 1) load you data into 2d numpy arrays (lats, lons, data). lats and lons must be in degrees (not radians). 2) create a Basemap instance (called "map") for the desired projection. 3) calculate the map projection coordinates of your grid with x,y = map(lons,lats) 4) contour your data with the contourf method (map.contourf). 5) draw coastlines with the coastlines method. 6) draw lat/lon lines with the drawparallels and drawmeridians methods. There are many examples of this in the basemap examples directory. -Jeff
Try the solution proposed at <http://groups.google.com/group/scitools/browse_thread/thread/b3ee1646bc453d72> Christoph On 1/20/2011 2:42 PM, David Williams wrote: > Hi folks > > I am teaching myself Python by working > through Hans Petter Langtangen's > excellent book "Primer on Scientific > Programming in Python". > > The exercises in chapter 4 of the book > require the student to use Python with > the freely downloadable tools > MatplotLib and SciTools to plot graphs > of mathematical functions. > > Despite downloading and installing > numerous different versions of Python > 2.x, MatPlotLib and SciTools, I am > unable to find a combination which > will work together without crashing. > > I'm currently using a Windows XP > laptop with: > Python 2.6.6 > IDLE 2.6.6 > MatplotLib 0.99,3 win32 Py2.6 > Scitools from > scipy-0.80-win32-superpack-python 2.6 > > When I try to run a simple script to > test the plotting functions, I get the > error messages attached below. > > I don't want to use Python 3, as there > still seem to be some teething > problems with this, and many of the > modules that I've already written or > need to use are not compatible with > Python 3.x. > > I've emailed the author, but have not > yet had a reply. > > I'd be very grateful if you could > explain why I get the error messages > shown below, what is a compatible > combination of versions of Python 2.x, > MatPlotLib and Scitools; and the URL > of sites where I can download these. > > Many thanks in anticipation > > > Dave > (UK) > > ============================= > Test script: > > 1. from scitools.std import * > 2. > 3. def f(t): > 4. return t**2*exp(-t**2) > 5. > 6. t = linspace(0,3,51) > 7. y = zeros(len(t)) > 8. for i in xrange(len(t)): > 9. y[i] = f(t[i]) > 10. > 11. plot(t,y) > 12. > 13. > > =============================== > >>>> > scitools.easyviz backend is matplotlib > > Traceback (most recent call last): > File "C:\Python\Dave_Book > Exercises4円_3_2 Plot test_DW.py", line > 11, in<module> > plot(t,y) > File > "C:\Python26\lib\site-packages\scitools\easyviz\common.py", > line 3060, in plot > self._replot() > File > "C:\Python26\lib\site-packages\scitools\easyviz\matplotlib_.py", > line 906, in _replot > self._g.draw() > File > "C:\Python26\lib\site-packages\matplotlib\pyplot.py", > line 352, in draw > get_current_fig_manager().canvas.draw() > File > "C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py", > line 215, in draw > FigureCanvasAgg.draw(self) > File > "C:\Python26\lib\site-packages\matplotlib\backends\backend_agg.py", > line 314, in draw > self.figure.draw(self.renderer) > File > "C:\Python26\lib\site-packages\matplotlib\artist.py", > line 46, in draw_wrapper > draw(artist, renderer, *args, > **kwargs) > File > "C:\Python26\lib\site-packages\matplotlib\figure.py", > line 773, in draw > for a in self.axes: a.draw(renderer) > File > "C:\Python26\lib\site-packages\matplotlib\artist.py", > line 46, in draw_wrapper > draw(artist, renderer, *args, > **kwargs) > File > "C:\Python26\lib\site-packages\matplotlib\axes.py", > line 1735, in draw > a.draw(renderer) > File > "C:\Python26\lib\site-packages\matplotlib\artist.py", > line 46, in draw_wrapper > draw(artist, renderer, *args, > **kwargs) > File > "C:\Python26\lib\site-packages\matplotlib\axis.py", > line 742, in draw > tick.draw(renderer) > File > "C:\Python26\lib\site-packages\matplotlib\artist.py", > line 46, in draw_wrapper > draw(artist, renderer, *args, > **kwargs) > File > "C:\Python26\lib\site-packages\matplotlib\axis.py", > line 196, in draw > self.label1.draw(renderer) > File > "C:\Python26\lib\site-packages\matplotlib\text.py", > line 518, in draw > bbox, info = > self._get_layout(renderer) > File > "C:\Python26\lib\site-packages\matplotlib\text.py", > line 280, in _get_layout > clean_line, self._fontproperties, > ismath=ismath) > File > "C:\Python26\lib\site-packages\matplotlib\backends\backend_agg.py", > line 148, in > get_text_width_height_descent > texmanager = self.get_texmanager() > File > "C:\Python26\lib\site-packages\matplotlib\backend_bases.py", > line 374, in get_texmanager > from matplotlib.texmanager import > TexManager > File > "C:\Python26\lib\site-packages\matplotlib\texmanager.py", > line 72, in<module> > class TexManager: > File > "C:\Python26\lib\site-packages\matplotlib\texmanager.py", > line 94, in TexManager > _dvipng_hack_alpha = > dvipng_hack_alpha() > File > "C:\Python26\lib\site-packages\matplotlib\texmanager.py", > line 68, in dvipng_hack_alpha > raise RuntimeError('Could not obtain > dvipng version') > RuntimeError: Could not obtain dvipng > version >>>> > > ------------------------------------------------------------------------------ > 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 I have a set of records with known lat long. I want to show the concentration of the records with a contour diagram on a world map in any projection. It cannot spill over to the oceans. I know I have to use basemap. Is there a quick recipe somewhere I can follow to give me a desired output. I have gone through earlier posts on this board but cannot find the right one. Any pointers would be very helpful. Many thanks. Best Mitra