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
(19) |
2
(28) |
3
(8) |
4
(15) |
5
(20) |
6
(23) |
7
(12) |
8
(11) |
9
(13) |
10
(4) |
11
(9) |
12
(34) |
13
(33) |
14
(24) |
15
(15) |
16
(12) |
17
(8) |
18
(5) |
19
(5) |
20
(6) |
21
(10) |
22
(9) |
23
(18) |
24
(10) |
25
(7) |
26
(13) |
27
(18) |
28
(29) |
29
(4) |
30
(5) |
31
(2) |
From: ifriad <if...@gm...> - 2009-10-31 09:16:00
|
Hi, Does any one knows how to do those cone plots, I am attaching a sample plot. Thanks Ihab http://old.nabble.com/file/p26140834/cone.png cone.png -- View this message in context: http://old.nabble.com/cone-plots-tp26140834p26140834.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
From: nbv4 <cp3...@oh...> - 2009-10-31 06:56:58
|
I'm trying to create a dynamically generated png of an arbitrary number of barplots. The height of the png should correspond with the number of plots that are made. In jpGraph this is very easy. All you have to do is set the height of the image to top-margin + (number_of_bars * width_of_bars) + bottom_margin. But matplotlib doesn't use pixels, so it's not as easy. Here is my code: def output(self): # titles = a list of the titles that get displayed down the left side # vals = a list of values that will determine how big to make each bar titles, vals = self.get_data() # set the height of each bar based on how many items there are from pylab import arange pos = arange(len(vals)) rects = self.ax.barh(pos, vals, height=0.8, # this doesn't seem to be in any sane unit align='center', color=self.bar_color) from pylab import yticks, xticks yticks(pos, map(self.make_ytick, titles)) xticks([], []) #remove everything from the x axis from pylab import title title(self.get_column_title() + " " + self.title()) self.annotate_bars(rects) # add the text to the end of each bar return self.fig then that fig is outputted like this: response=HttpResponse(content_type='image/png') fig = self.output() # this is the magic formula that needs to be changed # self.len is the number of bars there are # 0.15 inches per bar + 1 inch for margins fig.set_figheight((.15 * self.len) +1) fig.savefig(response, bbox_inches="tight", pad_inches=0.5, format='png') return response Here are some output examples of my code: http://sites.google.com/site/nbvfour/home As you can see, there are random swaths of whitespace at the top and bottom of each, and the bard are not consistent. Hoe can I fix this? Also, how do I get those ugly tick marks to go away wile still keeping the titles of each bar? -- View this message in context: http://old.nabble.com/dynamically-setting-the-height-of-a-barh-plot-tp26140259p26140259.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
From: Vicent M. <uv...@gm...> - 2009-10-30 20:30:20
|
> Dear Vicent, > > I'm struggling with embedding a navigation toolbar in a QT4 application > with matplotlib canvas. Could you please send me an example code of how I > add the navigation toolbar in the first place? > > As you notice, I'm a real newbe! > > Thank you very much, > > Thom > > Vicent Mas-2 wrote: > > Hi Matthias , > > > > thanks a lot for your explanations. They were very useful. > > > > Vicent > Hi, you can start here (it is what I did :-): http://eli.thegreenplace.net/2009/05/23/more-pyqt-plotting-demos/ Hope it helps. Vicent :: Share what you know, learn what you don't |
From: Thomas S. <tho...@gm...> - 2009-10-30 19:32:35
|
Hi, I was checking out matplotlib, and tried running the example shown on the front page (http://matplotlib.sourceforge.net/), but no window showed itself. I had to look through the examples files to find out how to make it work: it needed a show() command at the end. I think that the example should be complete enough for the prospective user to actually get a pretty picture... not just leave one hanging with <a list of 100 Patch objects> Thanks, -Thomas |
From: Jae-Joon L. <lee...@gm...> - 2009-10-30 18:42:59
|
I don't see such problem in my installations. I may be wrong but It seems to me that it is a font issue (I believe you're not using usetex mode). Can you try to use other fonts? For example, my current installation picks up the following font (Vera Serif?). In [10]: matplotlib.font_manager.findfont(None) Out[10]: '/astro/research/jul27/local/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/VeraSe.ttf' Regards, -JJ 2009/10/30 Johan Grönqvist <joh...@gm...>: > Hello List, > > I am so far happy with the output form matplotlib, but I recently started > annotating my plots, and when saving to png-format, the annotations do not > look very nice. When saving to eps format, I do not see the same problems. > > Saving to eps and converting to png seems to be a good workaround for me. > > The problem is that the letters in the same word (on the same line) are not > aligned, some are drawn to far up or down. > > png and eps figures are attached. Example script and version number (0.99.0) > below. > > Am I misusing matplotlib? Is this a bug? > > > Regards > > johan > > > > > > > > > Minimal example: > ----------------------- > import matplotlib.pyplot as plt > import numpy as np > > plt.figure() > > x = [0] > plt.plot(x, x) > > plt.annotate("units are important, $7.64358$, > $\\frac{\mathrm{k}\mathrm{m}}{\mathrm{s^2}}$", > xy = (0,0), > xycoords = "data", > xytext = (0.2, 0.6), > textcoords = "figure fraction", > arrowprops = dict(arrowstyle = "->", > connectionstyle = "arc")) > > > plt.savefig("pyplot_text.png") > plt.savefig("pyplot_text.eps") > plt.show() > ----------------------- > > > Expected result: An empty plot with a nice annotation on screen, in a > png-file, and in an eps-file > > Result: Empty plots with annotation displaying differently in the three > cases. In the png file, the letters u and r and the digit 7 appear slightly > above the correct position, and the m in the unit km appears slightly below > the correct position. In the screen output, the m is correct, but the u and > r show the same problem as in the png file. In the eps file, all seems to be > well. > > My os is debian (testing), and I obtain matplotlib and all related software > from the debian repositories. > > johan@johan-laptop:~$ uname -a > Linux johan-laptop 2.6.30-2-amd64 #1 SMP Fri Sep 25 22:16:56 UTC 2009 x86_64 > GNU/Linux > johan@johan-laptop:~$ python -c "import matplotlib; print > matplotlib.__version__" > 0.99.0 > > > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |
From: Thomba <tho...@ho...> - 2009-10-30 10:38:42
|
Dear Vicent, I'm struggling with embedding a navigation toolbar in a QT4 application with matplotlib canvas. Could you please send me an example code of how I add the navigation toolbar in the first place? As you notice, I'm a real newbe! Thank you very much, Thom Vicent Mas-2 wrote: > > Hi Matthias , > > thanks a lot for your explanations. They were very useful. > > Vicent > > -- > Share what you know, learn what you don't. > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- View this message in context: http://old.nabble.com/pan-zoom-axes-problem-tp25274703p26127910.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
From: Johan G. <joh...@gm...> - 2009-10-30 09:40:17
|
Hello List, I am so far happy with the output form matplotlib, but I recently started annotating my plots, and when saving to png-format, the annotations do not look very nice. When saving to eps format, I do not see the same problems. Saving to eps and converting to png seems to be a good workaround for me. The problem is that the letters in the same word (on the same line) are not aligned, some are drawn to far up or down. png and eps figures are attached. Example script and version number (0.99.0) below. Am I misusing matplotlib? Is this a bug? Regards johan Minimal example: ----------------------- import matplotlib.pyplot as plt import numpy as np plt.figure() x = [0] plt.plot(x, x) plt.annotate("units are important, $7.64358$, $\\frac{\mathrm{k}\mathrm{m}}{\mathrm{s^2}}$", xy = (0,0), xycoords = "data", xytext = (0.2, 0.6), textcoords = "figure fraction", arrowprops = dict(arrowstyle = "->", connectionstyle = "arc")) plt.savefig("pyplot_text.png") plt.savefig("pyplot_text.eps") plt.show() ----------------------- Expected result: An empty plot with a nice annotation on screen, in a png-file, and in an eps-file Result: Empty plots with annotation displaying differently in the three cases. In the png file, the letters u and r and the digit 7 appear slightly above the correct position, and the m in the unit km appears slightly below the correct position. In the screen output, the m is correct, but the u and r show the same problem as in the png file. In the eps file, all seems to be well. My os is debian (testing), and I obtain matplotlib and all related software from the debian repositories. johan@johan-laptop:~$ uname -a Linux johan-laptop 2.6.30-2-amd64 #1 SMP Fri Sep 25 22:16:56 UTC 2009 x86_64 GNU/Linux johan@johan-laptop:~$ python -c "import matplotlib; print matplotlib.__version__" 0.99.0 |
From: Jeff W. <js...@fa...> - 2009-10-29 22:41:51
|
Ros...@ga... wrote: > -----Original Message----- > <snip> > >> Maybe I'm just extra ignorant today, but why *shouldn't* a scale be drawn on a 'cyl' projection???? >> >> > <snip> > > Ross: Because a cylindrical projection isn't really a projection at all > - it's just a lat/lon coordinate system. > > -Jeff > > <snip> > -----Original Message----- > > Hi Jeff, > > Yes, surely, cylindrical isn't a real hairy-chested projection like Mercator, et al, yet I can create a map with the 'Equidistant Cylindrical Projection' and a scale has just as much meaning on a cylindrical 'projection' as any other. > > That is, the semantics of the drawmapscale() method have meaning, even in cyclindrical: "draw an annotation at this point representing the scale at that other _point_". Yes, as you move away from the point the scale annotation is representing the errors grow, but that is true of many projections. True, the errors for cylindrical projections get rather large, especially in the higher latitudes, but that just means the creator/user must understand the limitations. > > Ross > Ross: You're right, I guess the real reason is that when you create a basemap instance with projection='cyl', then do x,y = map(lon, lat) # map is a Basemap instance for projection='cyl' nothing happens - that is x,y are still longitudes and latitudes in degrees. So, there is nothing from which to compute a map scale, since no projection is happening. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
From: <Ros...@ga...> - 2009-10-29 22:12:39
|
-----Original Message----- <snip> > Maybe I'm just extra ignorant today, but why *shouldn't* a scale be drawn on a 'cyl' projection???? > <snip> Ross: Because a cylindrical projection isn't really a projection at all - it's just a lat/lon coordinate system. -Jeff <snip> -----Original Message----- Hi Jeff, Yes, surely, cylindrical isn't a real hairy-chested projection like Mercator, et al, yet I can create a map with the 'Equidistant Cylindrical Projection' and a scale has just as much meaning on a cylindrical 'projection' as any other. That is, the semantics of the drawmapscale() method have meaning, even in cyclindrical: "draw an annotation at this point representing the scale at that other _point_". Yes, as you move away from the point the scale annotation is representing the errors grow, but that is true of many projections. True, the errors for cylindrical projections get rather large, especially in the higher latitudes, but that just means the creator/user must understand the limitations. Ross |
From: Jeff W. <js...@fa...> - 2009-10-29 15:25:04
|
Ros...@ga... wrote: > Hi all, > > Sorry if this has been discussed before, but I can't find any previous threads on this. > > I'm trying to draw a scale on an equidistant cylindrical projection, and I'm seeing a ValueError exception with the message: > Cannot draw map scale for projection='cyl' > > And indeed, in basemap/__init__.py (about line 3286, 0.99.4) there is an explicit test for the 'cyl' projection and a raise of the above exception. > > Maybe I'm just extra ignorant today, but why *shouldn't* a scale be drawn on a 'cyl' projection???? > > Thanks, > Ross > Ross: Because a cylindrical projection isn't really a projection at all - it's just a lat/lon coordinate system. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
From: <Ros...@ga...> - 2009-10-29 06:01:51
|
Hi all, Sorry if this has been discussed before, but I can't find any previous threads on this. I'm trying to draw a scale on an equidistant cylindrical projection, and I'm seeing a ValueError exception with the message: Cannot draw map scale for projection='cyl' And indeed, in basemap/__init__.py (about line 3286, 0.99.4) there is an explicit test for the 'cyl' projection and a raise of the above exception. Maybe I'm just extra ignorant today, but why *shouldn't* a scale be drawn on a 'cyl' projection???? Thanks, Ross |
From: Phillip M. F. <pfe...@ve...> - 2009-10-28 23:57:53
|
This is tremendous. thanks!! Phillip Jae-Joon Lee wrote: > On Wed, Oct 28, 2009 at 7:20 PM, Phillip M. Feldman > <pfe...@ve...> wrote: > >> If I get one y-axis with the 'host', and each invocation of twinx adds >> another y-axis, then it seems that I must invoke twinx three times to get >> four y-axes. Does twinx add more than one y-axis per invocation? (The >> documentation that I've been able to find is ambiguous about this). >> > > twinx add a single axes. > In your original code, you were calling twinx 4-times. > > See if the attached code works. > > While I acknowledge that using spines with multiple y-axis is a bit > tricky, I don't think the situation will change anytime soon. > > Regards, > > -JJ > |
From: Jae-Joon L. <lee...@gm...> - 2009-10-28 23:45:43
|
On Wed, Oct 28, 2009 at 7:20 PM, Phillip M. Feldman <pfe...@ve...> wrote: > If I get one y-axis with the 'host', and each invocation of twinx adds > another y-axis, then it seems that I must invoke twinx three times to get > four y-axes. Does twinx add more than one y-axis per invocation? (The > documentation that I've been able to find is ambiguous about this). twinx add a single axes. In your original code, you were calling twinx 4-times. See if the attached code works. While I acknowledge that using spines with multiple y-axis is a bit tricky, I don't think the situation will change anytime soon. Regards, -JJ |
From: Phillip M. F. <pfe...@ve...> - 2009-10-28 23:27:50
|
# multiple_yaxes_with_spines.py # This is a template Python program for creating plots (line graphs) with 2, 3, # or 4 y-axes. (A template program is one that you can readily modify to meet # your needs). Almost all user-modifiable code is in Section 2. For most # purposes, it should not be necessary to modify anything else. # Dr. Phillip M. Feldman, 27 Oct, 2009 # Acknowledgment: This program is based on code written by Jae-Joon Lee, # URL= http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/ # examples/pylab_examples/multiple_yaxis_with_spines.py?revision=7908&view=markup # Section 1: Import modules, define functions, and allocate storage. import matplotlib.pyplot as plt from numpy import * def make_patch_spines_invisible(ax): ax.set_frame_on(True) ax.patch.set_visible(False) for sp in ax.spines.itervalues(): sp.set_visible(False) def set_spine_direction(ax, direction): if direction in ["right", "left"]: ax.yaxis.set_ticks_position(direction) ax.yaxis.set_label_position(direction) elif direction in ["top", "bottom"]: ax.xaxis.set_ticks_position(direction) ax.xaxis.set_label_position(direction) else: raise ValueError("Unknown Direction: %s" % (direction,)) ax.spines[direction].set_visible(True) # Create list to store dependent variable data: y= [0, 0, 0, 0] # Section 2: Define names of variables and the data to be plotted. # `labels` stores the names of the independent and dependent variables). The # first (zeroth) item in the list is the x-axis label; remaining labels are the # first y-axis label, second y-axis label, and so on. There must be at least # two dependent variables and not more than four. labels= ['Indep. Variable', 'Dep. Variable #1', 'Dep. Variable #2', 'Dep. Variable #3', 'Dep. Variable #4'] # Plug in your data here, or code equations to generate the data if you wish to # plot mathematical functions. x stores values of the independent variable; # y[0], y[1], ... store values of the dependent variables. Each of these should # be a NumPy array. # If you are plotting mathematical functions, you will probably want an array of # uniformly spaced values of x; such an array can be created using the # `linspace` function. For example, to define x as an array of 51 values # uniformly spaced between 0 and 2, use the following command: # x= linspace(0., 2., 51) # Here is an example of 6 experimentally measured values for the first dependent # variable: # y[0]= array( [3, 2.5, 7.3e4, 4, 8, 3] ) # Note that the above statement requires both parentheses and square brackets. # With a bit of work, one could make this program read the data from a text file # or Excel worksheet. # Independent variable: x= linspace(0., 2., 51) # First dependent variable: y[0]= sqrt(x) # Second dependent variable: y[1]= 0.2 + x**0.3 - 0.1*x**2 y[2]= 30.*sin(1.5*x) y[3]= 30.*abs(cos(1.5*x)) # Set line colors here; each color can be specified using a single-letter color # identifier ('b'= blue, 'r'= red, 'g'= green, 'k'= black, 'y'= yellow, # 'm'= magenta, 'y'= yellow), an RGB tuple, or almost any standard English color # name written without spaces, e.g., 'darkred'. colors= ['b', 'darkred', 'g', 'magenta'] # Set the line width here. linewidth=2 is recommended. linewidth= 2 # Set the axis label size in points here. 16 is recommended. axis_label_size= 16 # Section 3: Generate the plot. N_dependents= len(labels) - 1 if N_dependents > 4: raise Exception, \ 'This code currently handles a maximum of four independent variables.' # Open a new figure window, setting the size to 10-by-7 inches and the facecolor # to white: fig= plt.figure(figsize=(10,7), dpi=120, facecolor=[1,1,1]) host= fig.add_subplot(111) # Use twinx() to create extra axes for all dependent variables except the first # (we get the first as part of the host axes). y_axis= N_dependents * [0] y_axis[0]= host for i in range(1,N_dependents): y_axis[i]= host.twinx() if N_dependents >= 3: # The following statement positions the third y-axis to the right of the # frame, with the space between the frame and the axis controlled by the # numerical argument to set_position; this value should be between 1.10 and # 1.2. y_axis[2].spines["right"].set_position(("axes", 1.15)) make_patch_spines_invisible(y_axis[2]) set_spine_direction(y_axis[2], "right") plt.subplots_adjust(left=0.0, right=0.8) if N_dependents >= 4: # The following statement positions the fourth y-axis to the left of the # frame, with the space between the frame and the axis controlled by the # numerical argument to set_position; this value should be between 1.10 and # 1.2. y_axis[3].spines["left"].set_position(("axes", -0.15)) make_patch_spines_invisible(y_axis[3]) set_spine_direction(y_axis[3], "left") plt.subplots_adjust(left=0.2, right=0.8) p= N_dependents * [0] # Plot the curves: for i in range(N_dependents): p[i], = y_axis[i].plot(x, y[i], colors[i], linewidth=linewidth, label=labels[i]) # Set axis limits. Use ceil() to force upper y-axis limits to be round numbers. host.set_xlim(x.min(), x.max()) # Label the x-axis: host.set_xlabel(labels[0], size=axis_label_size) for i in range(N_dependents): # Label the y-axis and set text color: y_axis[i].set_ylabel(labels[i+1], size=axis_label_size) y_axis[i].yaxis.label.set_color(colors[i]) # If you want to override the default axis limits, uncomment the following # line of code and adjust arguments appropriately: # y_axis[i].set_ylim(0.0, ceil(y[i].max())) if i== 1: y_axis[i].set_ylim(0.0, 1.5) j= 0 for sp in y_axis[i].spines.itervalues(): if j==i: sp.set_color(colors[i]) j+= 1 for obj in y_axis[i].yaxis.get_ticklines(): # `obj` is a matplotlib.lines.Line2D instance obj.set_color(colors[i]) obj.set_markeredgewidth(3) for obj in y_axis[i].yaxis.get_ticklabels(): obj.set_color(colors[i]) obj.set_size(12) obj.set_weight(600) # To enable the legend, uncomment the following two lines: # lines= p[1:] # host.legend(lines, [l.get_label() for l in lines]) plt.draw(); plt.show() |
From: Phillip M. F. <pfe...@ve...> - 2009-10-28 23:21:17
|
# multiple_yaxes_with_spines.py # This is a template Python program for creating plots (line graphs) with 2, 3, # or 4 y-axes. (A template program is one that you can readily modify to meet # your needs). Almost all user-modifiable code is in Section 2. For most # purposes, it should not be necessary to modify anything else. # Dr. Phillip M. Feldman, 27 Oct, 2009 # Acknowledgment: This program is based on code written by Jae-Joon Lee, # URL= http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/ # examples/pylab_examples/multiple_yaxis_with_spines.py?revision=7908&view=markup # Section 1: Import modules, define functions, and allocate storage. import matplotlib.pyplot as plt from numpy import * def make_patch_spines_invisible(ax): ax.set_frame_on(True) ax.patch.set_visible(False) for sp in ax.spines.itervalues(): sp.set_visible(False) def set_spine_direction(ax, direction): if direction in ["right", "left"]: ax.yaxis.set_ticks_position(direction) ax.yaxis.set_label_position(direction) elif direction in ["top", "bottom"]: ax.xaxis.set_ticks_position(direction) ax.xaxis.set_label_position(direction) else: raise ValueError("Unknown Direction: %s" % (direction,)) ax.spines[direction].set_visible(True) # Create list to store dependent variable data: y= [0, 0, 0, 0] # Section 2: Define names of variables and the data to be plotted. # `labels` stores the names of the independent and dependent variables). The # first (zeroth) item in the list is the x-axis label; remaining labels are the # first y-axis label, second y-axis label, and so on. There must be at least # two dependent variables and not more than four. labels= ['Indep. Variable', 'Dep. Variable #1', 'Dep. Variable #2', 'Dep. Variable #3', 'Dep. Variable #4'] # Plug in your data here, or code equations to generate the data if you wish to # plot mathematical functions. x stores values of the independent variable; # y[0], y[1], ... store values of the dependent variables. Each of these should # be a NumPy array. # If you are plotting mathematical functions, you will probably want an array of # uniformly spaced values of x; such an array can be created using the # `linspace` function. For example, to define x as an array of 51 values # uniformly spaced between 0 and 2, use the following command: # x= linspace(0., 2., 51) # Here is an example of 6 experimentally measured values for the first dependent # variable: # y[0]= array( [3, 2.5, 7.3e4, 4, 8, 3] ) # Note that the above statement requires both parentheses and square brackets. # With a bit of work, one could make this program read the data from a text file # or Excel worksheet. # Independent variable: x= linspace(0., 2., 51) # First dependent variable: y[0]= sqrt(x) # Second dependent variable: y[1]= 0.2 + x**0.3 - 0.1*x**2 y[2]= 30.*sin(1.5*x) y[3]= 30.*abs(cos(1.5*x)) # Set line colors here; each color can be specified using a single-letter color # identifier ('b'= blue, 'r'= red, 'g'= green, 'k'= black, 'y'= yellow, # 'm'= magenta, 'y'= yellow), an RGB tuple, or almost any standard English color # name written without spaces, e.g., 'darkred'. colors= ['b', 'darkred', 'g', 'magenta'] # Set the line width here. linewidth=2 is recommended. linewidth= 2 # Set the axis label size in points here. 16 is recommended. axis_label_size= 16 # Section 3: Generate the plot. N_dependents= len(labels) - 1 if N_dependents > 4: raise Exception, \ 'This code currently handles a maximum of four independent variables.' # Open a new figure window, setting the size to 10-by-7 inches and the facecolor # to white: fig= plt.figure(figsize=(10,7), dpi=120, facecolor=[1,1,1]) host= fig.add_subplot(111) # Use twinx() to create extra axes for all dependent variables except the first # (we get the first as part of the host axes). y_axis= N_dependents * [0] y_axis[0]= host for i in range(1,len(labels)): y_axis[i-1]= host.twinx() if N_dependents >= 3: # The following statement positions the third y-axis to the right of the # frame, with the space between the frame and the axis controlled by the # numerical argument to set_position; this value should be between 1.10 and # 1.2. y_axis[2].spines["right"].set_position(("axes", 1.15)) make_patch_spines_invisible(y_axis[2]) set_spine_direction(y_axis[2], "right") plt.subplots_adjust(left=0.0, right=0.8) if N_dependents >= 4: # The following statement positions the fourth y-axis to the left of the # frame, with the space between the frame and the axis controlled by the # numerical argument to set_position; this value should be between 1.10 and # 1.2. y_axis[3].spines["left"].set_position(("axes", -0.15)) make_patch_spines_invisible(y_axis[3]) set_spine_direction(y_axis[3], "left") plt.subplots_adjust(left=0.2, right=0.8) p= N_dependents * [0] # Plot the curves: for i in range(N_dependents): p[i], = y_axis[i].plot(x, y[i], colors[i], linewidth=linewidth, label=labels[i]) # Set axis limits. Use ceil() to force upper y-axis limits to be round numbers. host.set_xlim(x.min(), x.max()) # Label the x-axis: host.set_xlabel(labels[0], size=axis_label_size) for i in range(N_dependents): # Label the y-axis and set text color: y_axis[i].set_ylabel(labels[i+1], size=axis_label_size) y_axis[i].yaxis.label.set_color(colors[i]) # If you want to override the default axis limits, uncomment the following # line of code and adjust arguments appropriately: # y_axis[i].set_ylim(0.0, ceil(y[i].max())) if i== 1: y_axis[i].set_ylim(0.0, 1.5) j= 0 for sp in y_axis[i].spines.itervalues(): if j==i: sp.set_color(colors[i]) j+= 1 for obj in y_axis[i].yaxis.get_ticklines(): # `obj` is a matplotlib.lines.Line2D instance obj.set_color(colors[i]) obj.set_markeredgewidth(3) for obj in y_axis[i].yaxis.get_ticklabels(): obj.set_color(colors[i]) obj.set_size(12) obj.set_weight(600) # To enable the legend, uncomment the following two lines: # lines= p[1:] # host.legend(lines, [l.get_label() for l in lines]) plt.draw(); plt.show() |
From: Jae-Joon L. <lee...@gm...> - 2009-10-28 22:08:12
|
On Tue, Oct 27, 2009 at 11:12 PM, Dr. Phillip M. Feldman <pfe...@ve...> wrote: > (1) Not only is the y-axis for dependent variable #1 blue (as it should be), > but the entire frame around the plot is blue. > at line 158, you're changing the color of all spines. Change the color of spine that you only want to change. > (2) The y-axis for dependent variable #2 has two sets of tick labels. The > set in black contains the correct values in the correct positions, but has > the wrong color. The other set of tick labels has the correct color (dark > red), but the values and locations are wrong. (In fact, these are same > values and positions as for dependent variable #1). At line 113, you're creating 4 twinx axes, instead of 3, i.e, the figure has total of 5 axes. Also, I recommend you to use the pythonic convention that list index starts from 0. Regards, -JJ |
From: Jae-Joon L. <lee...@gm...> - 2009-10-28 21:48:45
|
On Wed, Oct 28, 2009 at 9:55 AM, Michael Droettboom <md...@st...> wrote: > Does anyone with more experience with the scientific notation/offset > code have any further comments? While it is possible to turn off using the offset (or setting it manually), the api is not very friendly. fmt = gca().xaxis.get_major_formatter() fmt._useOffset = False fmt.offset = 0 Regards, -JJ |
From: Stan W. <sta...@nr...> - 2009-10-28 16:20:17
|
From: Piter_ [mailto:x....@gm...] Sent: Tuesday, October 27, 2009 14:37 Hi all. I have a problem with loading file of following format: first 1024 rows are tab delimited and contain from 2 to 256 elements (in different files different number of columns) after that 5 empty lines and at the end some 20 text lines for description. Although the following isn't specific to matplotlib, I submit it for the sake of others who may have similar questions about reading text data. Because a file object may be iterated, one can use the itertools module. In particular, the islice iterator allows you to select the start and stop lines and the step. So, you can read the desired portion of the file into a list of rows, splitting each row into a list of text tokens, then use numpy.array to convert the list into a numeric array. For example, # Begin code import numpy as np import itertools from __future__ import with_statement # no longer required in Python 2.6 with open('filename.dat') as f: a = np.array( [line.rstrip().split('\t') for line in itertools.islice(f, 1024)], dtype=np.float) # End code Just alter the islice arguments and dtype as necessary to suit your file. Documentation: * http://docs.python.org/library/stdtypes.html#file.next * http://docs.python.org/library/itertools.html#itertools.islice * http://docs.scipy.org/doc/numpy-1.3.x/reference/generated/numpy.array.html * http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html |
From: Tinne De L. <tin...@me...> - 2009-10-28 15:04:53
|
On Wed, Oct 28, 2009 at 2:59 PM, Michael Droettboom <md...@st...> wrote: > Eero Nevalainen wrote: >>> 2) forgot a factor 2 for the width and height (it's the entire width >>> not the `radius`) >>> >> >> I'd even say that this is a documentation bug in the Ellipse class. >> Too bad that they are multiplying by 0.5 inside their code :P >> > Well, it's not a good idea to change the existing behavior now, but we > can improve the documentation. What would you suggest? Would you > prefer to see the word "diameter" in there explicitly somehow? > > It currently says: > > *width* > length of horizontal axis > > *height* > length of vertical axis > I believe the documentation is just fine, but maybe the choices made for the ellipses parameters can be improved. I however I don't believe it is a very good idea to use non standard units like degrees .... You force your users to convert their output of mathematical calculations to non-standard units before being able to plot. I also think that the usage of radius in the circle patch is not consistent with using the length of the full horizontal axis of the ellipse patch .... Tinne |
From: Drain, T. R (343P) <the...@jp...> - 2009-10-28 14:55:31
|
We've had several users come to the same (incorrect) conclusion so I'd have to say it's not a rare occurrence for those comments to be misunderstood. Perhaps adding "total" in front of length would help. width- The total width of the ellipse > -----Original Message----- > From: Michael Droettboom [mailto:md...@st...] > Sent: Wednesday, October 28, 2009 6:59 AM > To: Eero Nevalainen > Cc: mat...@li... > Subject: Re: [Matplotlib-users] Drawing Error Ellipses > > Eero Nevalainen wrote: > >> 2) forgot a factor 2 for the width and height (it's the entire width > >> not the `radius`) > >> > > > > I'd even say that this is a documentation bug in the Ellipse class. > > Too bad that they are multiplying by 0.5 inside their code :P > > > Well, it's not a good idea to change the existing behavior now, but we > can improve the documentation. What would you suggest? Would you > prefer to see the word "diameter" in there explicitly somehow? > > It currently says: > > *width* > length of horizontal axis > > *height* > length of vertical axis > > Mike > > -- > Michael Droettboom > Science Software Branch > Operations and Engineering Division > Space Telescope Science Institute > Operated by AURA for NASA > > > ----------------------------------------------------------------------- > ------- > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart > your > developing skills, take BlackBerry mobile applications to market and > stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Eero N. <eer...@in...> - 2009-10-28 14:41:20
|
Michael Droettboom wrote: > Eero Nevalainen wrote: >>> 2) forgot a factor 2 for the width and height (it's the entire width >>> not the `radius`) >>> >> I'd even say that this is a documentation bug in the Ellipse class. >> Too bad that they are multiplying by 0.5 inside their code :P >> > Well, it's not a good idea to change the existing behavior now, but we > can improve the documentation. What would you suggest? Would you > prefer to see the word "diameter" in there explicitly somehow? > > It currently says: > > *width* > length of horizontal axis > > *height* > length of vertical axis OK, here are some proposals: 1. length (2a) of horizontal axis length (2b) of vertical axis 2. diameter of horizontal axis diameter of vertical axis 3. length (diameter) of horizontal axis length (diameter) of vertical axis 4. length (2r) of horizontal axis length (2r) of vertical axis I like number one the most. -- Eero Nevalainen System Architect Indagon Ltd. |
From: Michael D. <md...@st...> - 2009-10-28 13:59:46
|
Eero Nevalainen wrote: >> 2) forgot a factor 2 for the width and height (it's the entire width >> not the `radius`) >> > > I'd even say that this is a documentation bug in the Ellipse class. > Too bad that they are multiplying by 0.5 inside their code :P > Well, it's not a good idea to change the existing behavior now, but we can improve the documentation. What would you suggest? Would you prefer to see the word "diameter" in there explicitly somehow? It currently says: *width* length of horizontal axis *height* length of vertical axis Mike -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA |
From: Michael D. <md...@st...> - 2009-10-28 13:55:49
|
Jim Horning wrote: > Greetings, > > I've been having difficulties with axis limit control. From a bigger > application I've reduced an example down to the following short code > segment. Note, the commented-out line, #x = numpy.linspace(98.42, > 99.21, 100), line in which the example works OKAY. > > What is annoying is that the following example will produce a graph in > which the x-axis is labeled at ticks starting at 0.1 going to 0.35 > (times 1.474e2 !) Instead, I am expecting an axis from 147.63 to > 148.31. Note that if you swap out the x with the commented-out line > the example works like I would expect. First, a small bug in your example. I think you meant: pylab.xlim(numpy.min(x), numpy.min(x)) to be: pylab.xlim(numpy.min(x), numpy.max(x)) In the former case, when you have "unity" limits, matplotlib adds a small delta to the min and max so the range is not empty. Once this is fixed, the notation is actually ~0.1 to ~0.8 *plus* (not *times*) 1.474e2, which is at least correct, if not desired. The reason matplotlib does this is that, for space considerations, it avoids displaying ticks with more than 4 significant digits. Since the range here is so small, it prints the "offset" in the lower right and adjusts the ticks accordingly. Unfortunately, this number of significant digits isn't user customizable, though perhaps it should be (just as the range for scientific notation is). Can you file an enhancement request in the tracker so this doesn't get lost? Does anyone with more experience with the scientific notation/offset code have any further comments? Mike > > By the way, this example is with pylab. However, I've got the same > problem using plt from matplotlib or anything matplotlib related. > === > > import random > import numpy > import pylab > > #x = numpy.linspace(98.42, 99.21, 100) > x = numpy.linspace(147.63, 148.31, 100) > y = numpy.random.random((len(x))) > pylab.plot(x, y) > pylab.xlim(numpy.min(x), numpy.min(x)) > pylab.show() > > > -- > -------------------- > Jim A. Horning > ji...@ji... <mailto:ji...@ji...> > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > ------------------------------------------------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA |
From: Gökhan S. <gok...@gm...> - 2009-10-28 13:53:25
|
This movable legend is a good idea on plots, especially if there are many elements on one figure. However a few notes that I would like to add: 1-) So many lines of code. Makes it hard to read when I share the code with someone else. Would be so much better to have a functionality like: plt.legend(movable=True). I might add this into the feature request page, if one hasn't submitted yet. 2-) When I move the legend out of a canvas area, I can't bring back into the canvas, nor move it any longer. 3-) The rest of the toolbox items are gone. How to zoom or pan when I have a moving legend? Regards, On Tue, Oct 27, 2009 at 10:21 AM, Andrea Gavana <and...@gm...>wrote: > Hi Jae-Joon, > > 2009/10/26 Jae-Joon Lee: > > This is a known bug. While this is fixed in the svn, this did go into > > the maint. branch. > > As a workaround, add the following line after line 70. > > > > self.legend.set_axes(self.subplot) > > Thank you for your help, it works perfectly. > > Andrea. > > "Imagination Is The Only Weapon In The War Against Reality." > http://xoomer.alice.it/infinity77/ > http://thedoomedcity.blogspot.com/ > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Gökhan |
From: Eero N. <eer...@in...> - 2009-10-28 13:47:31
|
Thanks, and yes it looks better now :) Tinne De Laet wrote: > I still discoverd some problems with my plotEllipse function: > 1) the angle in the ellipsePlot expects and angle in DEGREES and not > in radians apparently so it seems > 2) forgot a factor 2 for the width and height (it's the entire width > not the `radius`) I'd even say that this is a documentation bug in the Ellipse class. Too bad that they are multiplying by 0.5 inside their code :P -- Eero Nevalainen System Architect Indagon Ltd. |