SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

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
(30)
3
(14)
4
(1)
5
(16)
6
(7)
7
(12)
8
(14)
9
(35)
10
(16)
11
(31)
12
(6)
13
(14)
14
(13)
15
(20)
16
(15)
17
(27)
18
(5)
19
(10)
20
(22)
21
(20)
22
(30)
23
(25)
24
(11)
25
(2)
26
(2)
27
(23)
28
(20)
29
(26)
30
(25)
31
(7)

Showing 21 results of 21

From: Jeff W. <js...@fa...> - 2009年07月27日 23:02:46
Angus McMorland wrote:
> Hi all,
>
> I've recently implemented a simple equal area (Lambert) projection in
> mpl, using two polar Axes (to draw each hemisphere), and this
> currently works fine to draw lines and points, since I'm transforming
> the points in my own code, from 3d-polar to 2d-projected-polar
> co-ordinates, and then plotting those.
>
> Now I have a need to also be able to draw coloured intensity maps on
> the Axes using the same transform, and I'm wondering what the best way
> to go about this would be. When I started the first implementation, I
> looked at basemap and its transforms, but they didn't seem to do what
> I wanted any more easily than just implementing it myself. 
Angus: I'm curious about how you came to this conclusion. It seems 
like this should be trivial in Basemap, in fact it's exactly what I 
designed it for.
If you send me a sample of your data, I can give you a simple script to 
plot it with Basemap.
-Jeff
> I'm also
> vaguely aware of some transformation capabilities (that are relatively
> new?) in mpl itself, but I'm not sure whether they're useful to me for
> polar co-ordinate systems and plot contents, rather than plot
> decorations. Ideally, the transform would apply to the interpolation
> too, but I think it would be sufficient to linearly interpolate
> between the points: I can simply provide them at high enough density
> to minimize the discrepancy.
>
> Any suggestions on the best way to do this would be gratefully received.
>
> Thanks,
>
> Angus.
> 
-- 
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: Angus M. <am...@gm...> - 2009年07月27日 22:23:21
Hi all,
I've recently implemented a simple equal area (Lambert) projection in
mpl, using two polar Axes (to draw each hemisphere), and this
currently works fine to draw lines and points, since I'm transforming
the points in my own code, from 3d-polar to 2d-projected-polar
co-ordinates, and then plotting those.
Now I have a need to also be able to draw coloured intensity maps on
the Axes using the same transform, and I'm wondering what the best way
to go about this would be. When I started the first implementation, I
looked at basemap and its transforms, but they didn't seem to do what
I wanted any more easily than just implementing it myself. I'm also
vaguely aware of some transformation capabilities (that are relatively
new?) in mpl itself, but I'm not sure whether they're useful to me for
polar co-ordinate systems and plot contents, rather than plot
decorations. Ideally, the transform would apply to the interpolation
too, but I think it would be sufficient to linearly interpolate
between the points: I can simply provide them at high enough density
to minimize the discrepancy.
Any suggestions on the best way to do this would be gratefully received.
Thanks,
Angus.
-- 
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh
From: Jae-Joon L. <lee...@gm...> - 2009年07月27日 22:01:17
On Mon, Jul 27, 2009 at 4:06 PM, Gewton Jhames<gj...@gm...> wrote:
> How to "trim the canvas" of the image generated? It's transparent, but still
> have a "padding", if it would be cropped, I can safe almost 200px!. I have
> attached a file to this email to show it, the background of the graph was
> set to red only to you see the padding.
As John suggested, you can adjust the subplot params. This adjusts the
area occupied by the axes, while the figure size (canvas size) is
fixed.
The subplot params can be automatically adjusted.
http://matplotlib.sourceforge.net/faq/howto_faq.html?highlight=automatic%20adjust#automatically-make-room-for-tick-labels
On the other hand, there is some crude support for trimming, i.e.,
reducing the figure size while the axes area fixed.
savefig("file.png", bbox_inches="tight")
Note that the figure size of the saved output is only affected. This
does not change the figure displayed on the screen.
Regards,
-JJ
From: dek <dr...@ho...> - 2009年07月27日 21:39:22
is there an on exit event for the matplotlib gui, such as when a user clicks
the 'x' in the gui window
-- 
View this message in context: http://www.nabble.com/on-exit-event--tp24688356p24688356.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: John H. <jd...@gm...> - 2009年07月27日 21:32:41
On Mon, Jul 27, 2009 at 3:06 PM, Gewton Jhames<gj...@gm...> wrote:
> Thanks everyone. Everything works perfectly.
> Only a few things left:
>
> How to "trim the canvas" of the image generated? It's transparent, but still
> have a "padding", if it would be cropped, I can safe almost 200px!. I have
> attached a file to this email to show it, the background of the graph was
> set to red only to you see the padding.
use
 fig.subplots_adjust(left=0.05, bottom=0.05, top=0.05, right=0.05)
etc to trim the excess space
> In the file attached to this email, the graph have a space after the
> position 23:00, I wish to remove it.
Several ways to do it: one is:
 ax.autoscale_view(tight=True, scaley=False)
Use
From: John H. <jd...@gm...> - 2009年07月27日 21:29:20
On Mon, Jul 27, 2009 at 10:55 AM, Tony S Yu<to...@mi...> wrote:
> Below is some code to do 1, 2, and 4.
> The 3rd issue is a bit more difficult. One approach is to use
> Jae-Joon's AxesGrid toolkit; you
> may need to be using the latest development version of matplotlib to use the toolkit.
> BTW, does anyone know why it's ``ax.set_axis_bgcolor`` instead of
> ``ax.set_facecolor``?
very old legacy where the axis background color "bgcolor" predated the
existance of an axes patch with the unified kwargs. If people want to
deprecate it in favor of
 ax.patch.set_facecolor(color)
I don't object.
JDH
From: Josh H. <jh...@vn...> - 2009年07月27日 20:53:08
Tony,
I know this is a year later but your code was hugely helpful to me last
week, so thank you. I needed to make a few modifications to get exactly what
I needed, so I thought I'd add to the post for posterity...
First, here is the graphic that the sample code generates (>>
execfile('radarPlotExample.py'):
http://www.nabble.com/file/p24688050/profileComparisonPub.png
profileComparisonPub.png 
Suffice it to say, I think this looks way better than what you get out of R
or MATLAB (e.g.
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=123).
Here is the code. I have tried to add comments in places that differ from
Tony's code. I am a relatively new Python and matplotlib convert, so please
feel free to comment on better ways to do this. But, like Tony said,
hopefully this will help someone.
Josh
---------------------------------------------------------------------------------------
radarPlotExample.py
---------------------------------------------------------------------------------------
from matplotlib.projections.polar import PolarAxes 
from matplotlib.projections import register_projection 
from pylab import * 
def radar_factory(num_vars, frame='polygon'): 
 """Create a radar chart with `num_vars` axes. 
 """ 
 # calculate evenly-spaced axis angles 
 theta = 2*pi * linspace(0, 1-1/float(num_vars), num_vars) 
 #print theta
 #print
 # rotate theta such that the first axis is at the top 
 theta += pi/2 
 
 def draw_poly_frame(self, x0, y0, r): 
 # TODO: should use transforms to convert (x, y) to (r, theta) 
 verts = [(r*cos(t) + x0, r*sin(t) + y0) for t in theta] 
 return Polygon(verts, closed=True) 
 
 def draw_circle_frame(self, x0, y0, r): 
 return Circle((x0, y0), r) 
 
 frame_dict = {'polygon': draw_poly_frame, 'circle': draw_circle_frame} 
 if frame not in frame_dict: 
 raise ValueError, 'unknown value for `frame`: %s' % frame 
 
 class RadarAxes(PolarAxes): 
 """Class for creating a radar chart (a.k.a. a spider or star chart) 
 
 http://en.wikipedia.org/wiki/Radar_chart 
 """ 
 name = 'radar' 
 # use 1 line segment to connect specified points 
 RESOLUTION = 1 
 # define draw_frame method 
 draw_frame = frame_dict[frame] 
 def fill(self, *args, **kwargs): 
 """Override fill so that line is closed by default""" 
 closed = kwargs.pop('closed', True) 
 return super(RadarAxes, self).fill(closed=closed, *args,
**kwargs) 
 
 def plot(self, *args, **kwargs): 
 """Override plot so that line is closed by default""" 
 lines = super(RadarAxes, self).plot(*args, **kwargs) 
 for line in lines: 
 self._close_line(line) 
 
 def _close_line(self, line): 
 x, y = line.get_data() 
 # FIXME: markers at x[0], y[0] get doubled-up 
 if x[0] != x[-1]: 
 x = concatenate((x, [x[0]])) 
 y = concatenate((y, [y[0]])) 
 line.set_data(x, y) 
 
 def set_varlabels(self, labels, rvals, rlabels): 
 self.set_thetagrids(theta * 180/pi, labels) 
 #Josh says: The rvals and rlabels parameters were added to
support
 #the call to the set_rgrid method so you can control the
position
 #and labelling of the circular grid lines. Make the radii labels 
 #smaller than the default size...
 self.set_rgrids(rvals, labels=rlabels, size='small')
 
 def get_axes_patch(self): 
 x0, y0 = (0.5, 0.5) 
 r = 0.5 
 return self.draw_frame(x0, y0, r)
 
 register_projection(RadarAxes) 
 return theta 
 
if __name__ == '__main__': 
 #The following data is from the Denver Aerosol Sources and Health study. 
 #See doi:10.1016/j.atmosenv.2008年12月01日7 
 #
 #The data are pollution source profile estimates for five modeled
pollution
 #sources (e.g., cars, wood-burning, etc) that emit 7-9 chemical species.
 #The radar charts are experimented with here to see if we can nicely 
 #visualize how the modeled source profiles change across four scenarios:
 # 1) No gas-phase species present, just seven particulate counts on
 # Sulfate
 # Nitrate
 # Elemental Carbon (EC)
 # Organic Carbon fraction 1 (OC)
 # Organic Carbon fraction 2 (OC2)
 # Organic Carbon fraction 3 (OC3)
 # Pyrolized Organic Carbon (OP)
 # 2)Inclusion of gas-phase specie carbon monoxide (CO) 
 # 3)Inclusion of gas-phase specie ozone (O3). 
 # 4)Inclusion of both gas-phase speciesis present...
 
 N = 9
 theta = radar_factory(N) 
 
 f1_base = [0.88, 0.01, 0.03, 0.03, 0.00, 0.06, 0.01, 0.00, 0.00]
 f1_CO = [0.88, 0.02, 0.02, 0.02, 0.00, 0.05, 0.00, 0.05, 0.00] 
 f1_O3 = [0.89, 0.01, 0.07, 0.00, 0.00, 0.05, 0.00, 0.00, 0.03] 
 f1_both = [0.87, 0.01, 0.08, 0.00, 0.00, 0.04, 0.00, 0.00, 0.01] 
 f2_base = [0.07, 0.95, 0.04, 0.05, 0.00, 0.02, 0.01, 0.00, 0.00]
 f2_CO = [0.08, 0.94, 0.04, 0.02, 0.00, 0.01, 0.12, 0.04, 0.00] 
 f2_O3 = [0.07, 0.95, 0.05, 0.04, 0.00, 0.02, 0.12, 0.00, 0.00] 
 f2_both = [0.09, 0.95, 0.02, 0.03, 0.00, 0.01, 0.13, 0.06, 0.00] 
 f3_base = [0.01, 0.02, 0.85, 0.19, 0.05, 0.10, 0.00, 0.00, 0.00]
 f3_CO = [0.01, 0.01, 0.79, 0.10, 0.00, 0.05, 0.00, 0.31, 0.00] 
 f3_O3 = [0.01, 0.02, 0.86, 0.27, 0.16, 0.19, 0.00, 0.00, 0.00] 
 f3_both = [0.01, 0.02, 0.71, 0.24, 0.13, 0.16, 0.00, 0.50, 0.00] 
 f4_base = [0.01, 0.01, 0.02, 0.71, 0.74, 0.70, 0.00, 0.00, 0.00]
 f4_CO = [0.00, 0.02, 0.03, 0.38, 0.31, 0.31, 0.00, 0.59, 0.00] 
 f4_O3 = [0.01, 0.03, 0.00, 0.32, 0.29, 0.27, 0.00, 0.00, 0.95] 
 f4_both = [0.01, 0.03, 0.00, 0.28, 0.24, 0.23, 0.00, 0.44, 0.88] 
 
 f5_base = [0.02, 0.01, 0.07, 0.01, 0.21, 0.12, 0.98, 0.00, 0.00]
 f5_CO = [0.02, 0.02, 0.11, 0.47, 0.69, 0.58, 0.88, 0.00, 0.00] 
 f5_O3 = [0.02, 0.00, 0.03, 0.37, 0.56, 0.47, 0.87, 0.00, 0.00] 
 f5_both = [0.02, 0.00, 0.18, 0.45, 0.64, 0.55, 0.86, 0.00, 0.16] 
 fig = figure(figsize=(9,9))
 fig.subplots_adjust(wspace=0.25, hspace=0.20)
 axlist = []
 axisNum = 0
 #The base vs with-gas ordering of the modeled profiles is swapped for 
 #factors 4/5, so we'll swap their ordering in the basecase list just to
keep 
 #the coloring consistent across the four plots...
 bases = [f1_base, f2_base, f3_base, f5_base, f4_base]
 COs = [f1_CO, f2_CO, f3_CO, f4_CO, f5_CO]
 O3s = [f1_O3, f2_O3, f3_O3, f4_O3, f5_O3]
 boths = [f1_both, f2_both, f3_both, f4_both, f5_both]
 everything = [bases, COs, O3s, boths]
 titles = ['Basecase', 'With CO', 'With O3', 'CO & O3']
 colors = ['b', 'r', 'g', 'm', 'y']
 for row in range(2):
 for col in range(2):
 axisNum += 1
 if axisNum == 2:
 #Unfortunately, it looks like the loc keyword to legend() is 
 #relative to a specific subplot, rather than the figure
itself. 
 #So, the positioning seen looks good, but if you resize the 
 #figure to be larger the legend becomes obviously bound to a 
 #specific subplot. This is in contrast to how the position
works
 #in something like figtext(). Had trouble using figlegend(),
but
 #need to try some more...
 legend(('Factor 1', 'Factor 2', 'Factor 3', 'Factor 4', 
 'Factor 5'), loc=(0.95, 0.895), borderpad=0.01, 
 shadow=False, prop=matplotlib.font_manager
 .FontProperties(size='smaller'), markerscale=0.4)
 
 data = everything[axisNum-1]
 ax = fig.add_subplot(2, 2, axisNum, projection='radar')
 ax.set_title(titles[axisNum-1], weight='bold', size='medium', 
 horizontalalignment='center', 
 verticalalignment='center',
backgroundcolor='white', 
 position=(0.5, 1.1))
 p1 = ax.plot(theta, data[0], color=colors[0]) 
 p2 = ax.plot(theta, data[1], color=colors[1])
 p3 = ax.plot(theta, data[2], color=colors[2])
 p4 = ax.plot(theta, data[3], color=colors[3])
 p5 = ax.plot(theta, data[4], color=colors[4])
 ax.fill(theta, data[0], facecolor=colors[0]) 
 ax.fill(theta, data[1], facecolor=colors[1]) 
 ax.fill(theta, data[2], facecolor=colors[2]) 
 ax.fill(theta, data[3], facecolor=colors[3]) 
 ax.fill(theta, data[4], facecolor=colors[4]) 
 #axlist.extend(ax) #This does not work because ax is a 
 #RadarAxesSubplot object, which is not
iterable
 axlist.append(ax) #append() works because it simply tacks on to 
 #the list, as opposed to merging items from
two
 #lists
 for patch in ax.patches: 
 patch.set_alpha(0.25) 
 
 figtext(0.5, 0.965, '5-Factor Solution Profiles Across Four Scenarios
', 
 ha='center', color='black', weight='bold', size='large') 
 
 #Crudely plot the grid lines I want to see: normalized concentrations of
 #chemicals range from 0 to 1...
 radiiGrid = [0.2, 0.4, 0.6, 0.8]
 theta_rgrid = radar_factory(100)
 for ax in axlist:
 for r in radiiGrid:
 radii = repeat(r, 100)
 ax.plot(theta_rgrid, radii, color='lightgrey')
 
 # FIXME: legend doesn't work when fill is called 
 spokeLabels = ['Sulfate', 'Nitrate', 'EC', 'OC1', 'OC2', 'OC3', 'OP',
'CO', 
 'O3']
 radiiLabels = [str(rg) for rg in radiiGrid]
 for ax in axlist:
 ax.set_varlabels(spokeLabels, radiiGrid, radiiLabels)
 show()
-- 
View this message in context: http://www.nabble.com/Radar---Spider-Chars-tp17876254p24688050.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Gewton J. <gj...@gm...> - 2009年07月27日 20:33:24
That's right Gökhan, I should have thought on it before ask. Thanks.
Only the first one remains... this one I could not find a way. I know there
is one class called FigureCanvasAgg, but I didn't find anything on it.
On Mon, Jul 27, 2009 at 5:16 PM, Gökhan SEVER <gok...@gm...> wrote:
> For the 2nd one;
>
> To re-position the figure content you might use axis(xmin= , xmax= )
>
>
> On Mon, Jul 27, 2009 at 3:06 PM, Gewton Jhames <gj...@gm...> wrote:
>
>> Thanks everyone. Everything works perfectly.
>> Only a few things left:
>>
>> 1. How to "trim the canvas" of the image generated? It's transparent,
>> but still have a "padding", if it would be cropped, I can safe almost
>> 200px!. I have attached a file to this email to show it, the background of
>> the graph was set to red only to you see the padding.
>> 2. In the file attached to this email, the graph have a space after
>> the position 23:00, I wish to remove it.
>>
>>
>> On Mon, Jul 27, 2009 at 1:37 PM, Jae-Joon Lee <lee...@gm...>wrote:
>>
>>> On Mon, Jul 27, 2009 at 11:55 AM, Tony S Yu<to...@mi...> wrote:
>>> > The 3rd issue is a bit more difficult. One approach is to use
>>> > Jae-Joon's AxesGrid toolkit; you
>>> >
>>> may need to be using the latest development version of matplotlib to use the toolkit.
>>>
>>> I think it would be easier to use the recently added spine support,
>>> because using the AxesGrid toolkit has some side-effects.
>>>
>>>
>>> http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html
>>>
>>> Regards,
>>>
>>> -JJ
>>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
>
> --
> Gökhan
>
From: Gökhan S. <gok...@gm...> - 2009年07月27日 20:16:22
For the 2nd one;
To re-position the figure content you might use axis(xmin= , xmax= )
On Mon, Jul 27, 2009 at 3:06 PM, Gewton Jhames <gj...@gm...> wrote:
> Thanks everyone. Everything works perfectly.
> Only a few things left:
>
> 1. How to "trim the canvas" of the image generated? It's transparent,
> but still have a "padding", if it would be cropped, I can safe almost
> 200px!. I have attached a file to this email to show it, the background of
> the graph was set to red only to you see the padding.
> 2. In the file attached to this email, the graph have a space after the
> position 23:00, I wish to remove it.
>
>
> On Mon, Jul 27, 2009 at 1:37 PM, Jae-Joon Lee <lee...@gm...>wrote:
>
>> On Mon, Jul 27, 2009 at 11:55 AM, Tony S Yu<to...@mi...> wrote:
>> > The 3rd issue is a bit more difficult. One approach is to use
>> > Jae-Joon's AxesGrid toolkit; you
>> >
>> may need to be using the latest development version of matplotlib to use the toolkit.
>>
>> I think it would be easier to use the recently added spine support,
>> because using the AxesGrid toolkit has some side-effects.
>>
>>
>> http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html
>>
>> Regards,
>>
>> -JJ
>>
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
-- 
Gökhan
From: Ryan M. <rm...@gm...> - 2009年07月27日 20:00:45
On Mon, Jul 27, 2009 at 2:40 PM, Christopher Barker
<Chr...@no...>wrote:
> Ryan May wrote:
>
>> > Put this in your ~/.ipython/ipythonrc:
>> >
>> > pylab_import_all 0
>>
>
> I finally got around to doing this, and found:
>
> # ===========================================================
> # Deprecation note: you should look into modifying ipy_user_conf.py
> (located
> # in ~/.ipython or ~/_ipython, depending on your platform) instead, it's a
> # more flexible and robust (and better supported!) configuration
> # method.
> # ===========================================================
>
> So I took that to heart, and added:
>
> o.pylab_import_all = 0
>
>
> to my ipy_user_conf.py file, and that had the same effect.
Good to know. When I get around to that FAQ entry, I'll be sure to include
that nugget.
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Eric F. <ef...@ha...> - 2009年07月27日 19:48:32
Paul Anton Letnes wrote:
> Hi,
> 
> 
> I'm having strange problems with contourf plots. The plotting routine is 
> rather elaborate, so I don't have an easy way to reproduce the problem 
> (unfortunately). The problem should be evident from the attachments. As 
> you can see, the contourf routine doesn't color the whole plot area. 
> Also, after some editing in Adobe Illustrator, it is also easy to see 
> that some contours are drawn on top of others. This must surely be a bug?
It is in your data file and/or your handling of it, not in contourf. 
The problem is that your theta variable is not monotonic--it starts and 
ends with zero. If you chop off the last line of your data file, or 
equivalently chop off the last column of each array after you read it, 
like this:
 return thetas[:,:-1], freqs[:,:-1], Es[:,:-1]
then the contouring works fine.
Eric
> 
> I would like to note that this happened on the TkAgg (using show()), Agg 
> (png format), ps (eps format), macosx (using show()) and pdf backends. 
> Also, for some data sets, the plot turns out just fine - I get this 
> problem only for some data sets. I have no idea how to debug this, so 
> I'd appreciate any hints you might provide.
> 
> The file original.pdf shows the matplotlib result. The file edited.pdf 
> shows that you have contours on top of each other. The file gnuplot.png 
> gives an idea of what the end result should be: a lot of bumps around 
> 3.5 eV, but some of this structure is missing from the contourf plots. 
> The gnuplot plot was generated from the same data (ASCII text) file.
> 
> 
> Best regards,
> Paul.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: per f. <per...@gm...> - 2009年07月27日 19:45:06
Hi all
i am making a scatter plot and want to label one of the points in the
legend. i run
scatter([x], [y], ..., label="mylabel")
and then run legend as follows
plt.legend(loc='lower right', numpoints=1, pad=0.01, labelsep=.01,
handlelen=.05)
i set numpoints=1 because i want it to show just one point and then its
label. however, this always generates a legend with three points, i.e.
o o o my label
rather than
o mylabel
does anyone know how to fix this? thank you.
From: Christopher B. <Chr...@no...> - 2009年07月27日 19:40:40
Ryan May wrote:
> > Put this in your ~/.ipython/ipythonrc:
> >
> > pylab_import_all 0
I finally got around to doing this, and found:
# ===========================================================
# Deprecation note: you should look into modifying ipy_user_conf.py 
(located
# in ~/.ipython or ~/_ipython, depending on your platform) instead, it's a
# more flexible and robust (and better supported!) configuration
# method.
# ===========================================================
So I took that to heart, and added:
 o.pylab_import_all = 0
to my ipy_user_conf.py file, and that had the same effect.
thanks,
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Jae-Joon L. <lee...@gm...> - 2009年07月27日 16:42:34
Well, I think the meaning of the axis("equal") is a bit misleading (at
least to me), but if you look at the documentation, it says that it
changes the xlimit and ylimit (limits in data coordinate), so this is
NOT what you want.
What you need is axis("scaled") or axis("image").
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.axis
With this, you will have square axes regardless of the figure size or
subplot params (assuming that the x- and y- data limits are same).
Regards,
-JJ
On Sun, Jul 26, 2009 at 8:43 PM, kbkb<kb...@js...> wrote:
>
> Thanks for trying to help Andreas.
>
> Those suggestions did not really solve the problem, but I did realize where
> I was going astray and post that information here to help others. I did see
> others new to the libraries looking for similar help.
>
> First the conceptual misunderstanding: I did not realize the 'figure size',
> as set by something like
> plt.gcf().set_size_inches(6,6) includes all area: white plot area, grey
> surrounding area, labels, etc. Everything inside the window frame. A bad
> coincidence slowed my realization. I measured the white area inside the
> axis to be 480x464 pixels, which at 80 dpi worked almost for a 6x6. So, I
> thought it was close but off just a bit. But, I had set the dpi to 100, and
> the total frame was exactly 600x600 as it should be. The dimensions of the
> plot area inside the axes was being set automatically, and just
> coincidentally worked out to be 480 in one dimension.
>
> Solution to get truly square plots of known size with axis scale set:
>  fig = plt.gcf()
>  fig.set_dpi(100) # or whatever you like
>  fig.set_size_inches((6.0,6.0),forward=True) #for example
>  # to control the fraction of the total area set aside for axis tick mark
> labels, etc.
>  # this is key to keeping the interior plot area square
>  plt.subplots_adjust(left=0.10,bottom=0.10,right=0.95,top=0.95)
>  ## plt.axis('equal') # I had this for a while but do not think it
> useful
>  plt.gca().grid(True)
>  # to keep the axis scale from being automatically changed as line2d
> objects are added or removed
>  plt.gca().set_autoscale_on(False)
>  plt.axis([1.0,9.0,1.0,9.0]) # set the axis scale as appropriate
>  plt.show()
>  fig.canvas.draw()
>
> Cheers
> Kersey
>
> --
> View this message in context: http://www.nabble.com/square-plots-with-linear-equal-axes-----help-tp24638812p24672100.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jae-Joon L. <lee...@gm...> - 2009年07月27日 16:37:51
On Mon, Jul 27, 2009 at 11:55 AM, Tony S Yu<to...@mi...> wrote:
> The 3rd issue is a bit more difficult. One approach is to use
> Jae-Joon's AxesGrid toolkit; you
> may need to be using the latest development version of matplotlib to use the toolkit.
I think it would be easier to use the recently added spine support,
because using the AxesGrid toolkit has some side-effects.
http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html
Regards,
-JJ
From: Tony S Yu <to...@MI...> - 2009年07月27日 15:55:28
Below is some code to do 1, 2, and 4.
The 3rd issue is a bit more difficult. One approach is to use Jae- 
Joon's AxesGrid toolkit; you may need to be using the latest 
development version of matplotlib to use the toolkit.
BTW, does anyone know why it's ``ax.set_axis_bgcolor`` instead of 
``ax.set_facecolor``?
Best,
-Tony
% ==============================
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure(frameon=False)
ax = plt.gca()
light_gray = (.8, .8, .8)
dark_gray = (.2, .2, .2)
x = np.random.random_integers(1, 10, 50)
n, bins, patches = ax.hist(x, facecolor='#658A2F')
for p in patches:
 p.set_edgecolor(dark_gray)
ax.set_axis_bgcolor(light_gray)
ax.yaxis.grid(color='w', linestyle='-')
# Assuming you want the gridlines below the bars
ax.set_axisbelow(True)
plt.show()
On Jul 27, 2009, at 11:22 AM, Gewton Jhames wrote:
> thanks!!
> only 4 left.
>
> On Mon, Jul 27, 2009 at 11:31 AM, Gökhan SEVER 
> <gok...@gm...> wrote:
> For the 5th one ;)
>
> figure(frameon=False)
>
> On Mon, Jul 27, 2009 at 8:26 AM, Gewton Jhames <gj...@gm...> 
> wrote:
> Hello, would you help me in some design issues that I wish to put in 
> my matplotlib graph?
> I want my graph look like the one that I'm attaching on this email:
>
> Change the Background-color of the axis to gray;
> Display only horizontal lines on the axis, in white color;
> Display only the border-left and the border-bottom of the graph, and 
> in 2px of width;
> Change the border-color of the bars of the graphics (to a more dark 
> gray).
> Save in a transparent png.
>
> Can anyone know how to change any of these features? thanks.
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> -- 
> Gökhan
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Jeff T. <jef...@gm...> - 2009年07月27日 15:33:38
Jae-Joon Lee,
The data file I worked with is:
The file 'unl-1mm-3d_MagMultiField_25.h5' (370.0 MB) is available for
download at
<
http://dropbox.unl.edu/uploads/20090803/b42af1d24f319f10/unl-1mm-3d_MagMultiField_25.h5
>
for the next 7 days.
It will be removed after Monday, August 3, 2009.
It contains a 4D array which we make into a 3D array. Then that is worked
with.
Adding the keyword argument aspect = 'auto' works for now. Though, in the
future I am not sure this will work for plotting data in different ways.
Today I will look into using the divider commands you give.
Thanks,
Jeff Thomas
On Sat, Jul 25, 2009 at 2:07 PM, Jae-Joon Lee <lee...@gm...> wrote:
> The axes_grid toolkit is base on use cases for images of aspect 1, and
> I haven't carefully considered cases where the aspect is different
> from 1. And I guess this is one of such cases I overlooked.
>
> Please try to add below lines in your code (I couldn't try your code
> because of the missing data file, but it works with the the scatter
> example you referred).
>
>
> ax.set_aspect("auto")
> divider.set_aspect(True)
> divider.get_horizontal()[0]._aspect=0.5
>
> The interface should be improved but I guess this will work.
>
> Regards,
>
> -JJ
>
>
> On Fri, Jul 24, 2009 at 1:19 PM, Jeff Thomas<jef...@gm...>
> wrote:
> > Currently, I am trying to plot a 2D array with imshow and two 1D arrays
> > on separate plots attached to the top and right of the imshow image. I
> got
> > it to work, however when I change the aspect of the image (which I want
> to
> > do) white space and unusual scalings appear. I want to get rid of it and
> > have the scales that match the aspect.
> > Basically, I want to do the same thing shown in the
> > example
> http://matplotlib.sourceforge.net/examples/axes_grid/scatter_hist.html
> > attached is the result with out the aspect change.
> > also attached is the result with aspect change attempt.
> > here is the code that produces the result above:
> > import numpy as np
> > import tables
> > from matplotlib.pyplot import *
> > import matplotlib as mpl
> > import matplotlib.cm as cm
> >
> >
> > fig = figure(figsize=[12.5,7.5])
> > from mpl_toolkits.axes_grid import make_axes_locatable
> > #get 3D array from hdf5 file
> > a =
> >
> tables.openFile("/Users/magoo/vorpal-data-2/unl-1mm-3d_ElecMultiField_25.h5")
> > b = a.root.ElecMultiField[ : , : , : ,1]
> > ax = fig.add_subplot(111)
> > ax.set_autoscale_on(False)
> > divider = make_axes_locatable(ax)
> > axLOutx = divider.new_vertical(1, pad=0.3, sharex=ax)
> > fig.add_axes(axLOutx)
> > #plot line above
> > axLOutx.plot(b[365,:,75])
> > axLOutx.set_xlim( (0,145))
> > axLOuty = divider.new_horizontal(2, pad=0.5, sharey=ax)
> > fig.add_axes(axLOuty)
> > #plot line on right
> > yarr = np.arange(0, np.shape(b[:, 75, 75])[0], 1)
> > axLOuty.plot(b[:,75,75], yarr)
> > axLOuty.set_ylim( (769,0))
> > # plot image/2D array
> > im = ax.imshow(b[:,:,75], extent=[0,145,769,0],cmap=cm.jet) # when I add
> > (aspect = .5) as another argument I get what is shown in the second
> attached
> > image
> > cb = colorbar(im, fraction=0.015)
> >
> > plt.draw()
> > plt.show()
> >
> ------------------------------------------------------------------------------
> >
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
>
From: Gewton J. <gj...@gm...> - 2009年07月27日 15:23:21
thanks!!
only 4 left.
On Mon, Jul 27, 2009 at 11:31 AM, Gökhan SEVER <gok...@gm...>wrote:
> For the 5th one ;)
>
> figure(frameon=False)
>
> On Mon, Jul 27, 2009 at 8:26 AM, Gewton Jhames <gj...@gm...> wrote:
>
>> Hello, would you help me in some design issues that I wish to put in my
>> matplotlib graph?
>> I want my graph look like the one that I'm attaching on this email:
>>
>>
>> - Change the Background-color of the axis to gray;
>> - Display only horizontal lines on the axis, in white color;
>> - Display only the border-left and the border-bottom of the graph, and
>> in 2px of width;
>> - Change the border-color of the bars of the graphics (to a more dark
>> gray).
>> - Save in a transparent png.
>>
>>
>> Can anyone know how to change any of these features? thanks.
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
>
> --
> Gökhan
>
From: Gökhan S. <gok...@gm...> - 2009年07月27日 14:31:36
For the 5th one ;)
figure(frameon=False)
On Mon, Jul 27, 2009 at 8:26 AM, Gewton Jhames <gj...@gm...> wrote:
> Hello, would you help me in some design issues that I wish to put in my
> matplotlib graph?
> I want my graph look like the one that I'm attaching on this email:
>
>
> - Change the Background-color of the axis to gray;
> - Display only horizontal lines on the axis, in white color;
> - Display only the border-left and the border-bottom of the graph, and
> in 2px of width;
> - Change the border-color of the bars of the graphics (to a more dark
> gray).
> - Save in a transparent png.
>
>
> Can anyone know how to change any of these features? thanks.
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
-- 
Gökhan
From: Denis-B <den...@t-...> - 2009年07月27日 11:33:44
<stack> in interpolate_one might be the time hog; I see claims that plain
<vector> is faster.
StackVector<int, 128> in
http://stackoverflow.com/questions/354442/looking-for-c-stl-like-vector-class-but-using-stack-storage 
looks nice, but I haven't timed it myself.
cheers
 -- denis
-- 
View this message in context: http://www.nabble.com/speeding-up-griddata%28%29-tp24467055p24679147.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: kbkb <kb...@js...> - 2009年07月27日 00:43:27
Thanks for trying to help Andreas.
Those suggestions did not really solve the problem, but I did realize where
I was going astray and post that information here to help others. I did see
others new to the libraries looking for similar help.
First the conceptual misunderstanding: I did not realize the 'figure size',
as set by something like
plt.gcf().set_size_inches(6,6) includes all area: white plot area, grey
surrounding area, labels, etc. Everything inside the window frame. A bad
coincidence slowed my realization. I measured the white area inside the
axis to be 480x464 pixels, which at 80 dpi worked almost for a 6x6. So, I
thought it was close but off just a bit. But, I had set the dpi to 100, and
the total frame was exactly 600x600 as it should be. The dimensions of the
plot area inside the axes was being set automatically, and just
coincidentally worked out to be 480 in one dimension.
Solution to get truly square plots of known size with axis scale set:
 fig = plt.gcf()
 fig.set_dpi(100) # or whatever you like
 fig.set_size_inches((6.0,6.0),forward=True) #for example
 # to control the fraction of the total area set aside for axis tick mark
labels, etc. 
 # this is key to keeping the interior plot area square
 plt.subplots_adjust(left=0.10,bottom=0.10,right=0.95,top=0.95) 
 ## plt.axis('equal') # I had this for a while but do not think it
useful
 plt.gca().grid(True)
 # to keep the axis scale from being automatically changed as line2d
objects are added or removed
 plt.gca().set_autoscale_on(False) 
 plt.axis([1.0,9.0,1.0,9.0]) # set the axis scale as appropriate
 plt.show() 
 fig.canvas.draw()
Cheers
Kersey
-- 
View this message in context: http://www.nabble.com/square-plots-with-linear-equal-axes-----help-tp24638812p24672100.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
2 messages has been excluded from this view by a project administrator.

Showing 21 results of 21

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /