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
(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)





Showing 15 results of 15

From: Benjamin R. <ben...@ou...> - 2011年01月24日 23:59:52
On Monday, January 24, 2011, Daniel Mader
<dan...@go...> wrote:
> Dear Paul,
>
> thank you very much for the quick reply! Unfortunately, I don't seem to get things right with your snippet of code:
>
>
>
> # prevent the automatic rotation caused by view changes
> ax.yaxis.set_rotate_label(False)
> ax.yaxis.label.set_rotation(45)
> Traceback (most recent call last):
>  File "example_mpl3D_spiral.py", line 41, in <module>
>   ax.yaxis.set_rotate_label(False)
> AttributeError: 'YAxis' object has no attribute 'set_rotate_label'
>
> Am I missing something?
>
> Thanks in advance,
> best regards from a snowed up Salzburg,
>
> Daniel
>
This problem with poorly rotated labels was fixed a couple of months
ago in the development branch and I believe it is also in 1.0.1. Just
to make sure, what version are you running?
Ben Root
From: Benjamin R. <ben...@ou...> - 2011年01月24日 23:56:52
On Monday, January 24, 2011, Russell Hewett <rhe...@il...> wrote:
> Worked great, thanks!
>
> -r
>
> On Mon, Jan 24, 2011 at 2:32 PM, Paul Ivanov <piv...@gm...> wrote:
>
> Russell Hewett, on 2011年01月24日 13:56, wrote:
>> Hi All,
>>
>> I can't get the x label on the top row of an ImageGrid to display if there
>> is more than one row in the grid. I suspect that something is being clipped
>> somewhere, but have no idea what to do to fix it. (Note, this also happens
>> on the right edge of a ride-sided y axis label.)
>>
>> I have included some minimal sample code below. I'd appreciate it if anyone
>> can point me in the right direction.
>>
>>
>> Cheers,
>> Russ
>
> Hi Russ,
>
> thanks for the report - at a glance, it appears to be a bug in
> AxesGrid removing redundant labels for shared axis when they
> align. I've included a temporary workaround for your script, but
> don't have time to look into it further at the moment. By the
> way, calling grid[0].axes is redundant, so I just modified it to
> use grid[0].xaxis, which is equivalent.
>
> #-------------------------------
> import matplotlib.pyplot as plt
> import matplotlib.cm as cm
> import mpl_toolkits.axes_grid1 as ag
>
> import numpy as np
>
> fig1 = plt.figure()
>
> grid1 = ag.AxesGrid( fig1, 111, nrows_ncols = (1,2), axes_pad = 0.5)
>
> grid1[0].xaxis.set_label_position('top')
> grid1[0].xaxis.set_label_text('foo')
>
> grid1[1].xaxis.set_label_position('top')
> grid1[1].xaxis.set_label_text('bar')
>
> grid1[0].yaxis.set_label_position('right')
> grid1[0].yaxis.set_label_text('foo')
>
> grid1[1].yaxis.set_label_position('right')
> grid1[1].yaxis.set_label_text('bar')
> grid1[1].yaxis.label.set_visible(True) # tmp workaround
>
>
> fig2 = plt.figure()
> grid2 = ag.AxesGrid( fig2, 111, nrows_ncols = (2,1), axes_pad = 0.5)
>
> grid2[0].xaxis.set_label_position('top')
> grid2[0].xaxis.set_label_text('bar')
> grid2[0].xaxis.label.set_visible(True) # tmp workaround
>
> grid2[1].xaxis.set_label_position('top')
> grid2[1].xaxis.set_label_text('bar')
>
> grid2[0].yaxis.set_label_position('right')
> grid2[0].yaxis.set_label_text('foo')
>
> grid2[1].yaxis.set_label_position('right')
> grid2[1].yaxis.set_label_text('bar')
>
> plt.show()
> #-------------------------------
>
> best,
> --
> Paul Ivanov
> 314 address only used for lists, off-list direct email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAk094eYACgkQe+cmRQ8+KPc/qACePreDR4ThGj/2PttN6OaMXm0K
> 17YAmwbIpf+++7fYVqI3asKiBf8Z3zlT
> =eG7W
> -----END PGP SIGNATURE-----
>
> ------------------------------------------------------------------------------
> 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
>
>
>
> --
> Russell J. Hewett
> Ph.D. Candidate
> Department of Computer Science
> University of Illinois at Urbana-Champaign
> www.russellhewett.com
>
>
Isn't it a feature? Axes_grid lets you choose the label mode which is
'L' by default. This means that only the outer labels are shown. Or
am I missing something in the description of the problem?
Ben Root
From: johanngoetz <jg...@uc...> - 2011年01月24日 23:06:07
Hello,
A common task I have is to histogram one variable of a multidimensional
dataset as a function of two (or more) variables. I have attached an example
which shows exactly what I would like to do.
The problem I would like to solve is the zoomed in x-axis which is the last
part of the script attached. I start by copying one of the subplots with
Axes.twiny() and proceed to adjust it and label it. The results are quite
nice but as soon as I start adjusting the plotted window or any of the
subplot spacing parameters, this "copy of an axis" does not transform
properly. Could anyone make a suggestion as to which transformations I
should use to shift and zoom the new axes? Or perhaps there is a better
method for drawing a zoomed in version of an axis?
I would like to submit this to the examples/gallery page but feel that these
details need to be addressed, and I am not sure I know how to fix them.
Hopefully, I have commented this example enough that someone could follow
what I am doing.
Thank you,
Johann
http://old.nabble.com/file/p30748088/grid_plot.png 
http://old.nabble.com/file/p30748088/grid_plot.py grid_plot.py 
-- 
View this message in context: http://old.nabble.com/zoomed-copy-of-axis-for-grid-of-subplots-tp30748088p30748088.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: C M <cmp...@gm...> - 2011年01月24日 22:30:21
On Mon, Jan 24, 2011 at 4:42 PM, Paul Ivanov <piv...@gm...> wrote:
> C M, on 2011年01月24日 16:27, wrote:
>> I looked through the gallery, but didn't see this one and am not sure
>> how to create it. It would be a "floating bar chart" (or floating
>> column chart), like what is seen here:
>>
>> http://peltiertech.com/Excel/pix1/BloodSugarFloater.gif
>
> Hi Che,
>
> just specify the 'bottom' keyword argument to bar. Note that the
> second parameter is height of the bar, *not* the top of the bar
>
> plt.bar([1,2,3,4], [2,2.5,5,3], bottom=[0,-1,1,2])
>
> best,
> --
> Paul Ivanov
Thanks, Paul! Easy enough.
-Che
From: Daniel M. <dan...@go...> - 2011年01月24日 21:50:20
Dear Paul,
thank you very much for the quick reply! Unfortunately, I don't seem to get
things right with your snippet of code:
# prevent the automatic rotation caused by view changes
> ax.yaxis.set_rotate_label(False)
> ax.yaxis.label.set_rotation(45)
>
Traceback (most recent call last):
 File "example_mpl3D_spiral.py", line 41, in <module>
 ax.yaxis.set_rotate_label(False)
AttributeError: 'YAxis' object has no attribute 'set_rotate_label'
Am I missing something?
Thanks in advance,
best regards from a snowed up Salzburg,
Daniel
From: Russell H. <rhe...@il...> - 2011年01月24日 21:46:31
Worked great, thanks!
-r
On Mon, Jan 24, 2011 at 2:32 PM, Paul Ivanov <piv...@gm...> wrote:
> Russell Hewett, on 2011年01月24日 13:56, wrote:
> > Hi All,
> >
> > I can't get the x label on the top row of an ImageGrid to display if
> there
> > is more than one row in the grid. I suspect that something is being
> clipped
> > somewhere, but have no idea what to do to fix it. (Note, this also
> happens
> > on the right edge of a ride-sided y axis label.)
> >
> > I have included some minimal sample code below. I'd appreciate it if
> anyone
> > can point me in the right direction.
> >
> >
> > Cheers,
> > Russ
>
> Hi Russ,
>
> thanks for the report - at a glance, it appears to be a bug in
> AxesGrid removing redundant labels for shared axis when they
> align. I've included a temporary workaround for your script, but
> don't have time to look into it further at the moment. By the
> way, calling grid[0].axes is redundant, so I just modified it to
> use grid[0].xaxis, which is equivalent.
>
> #-------------------------------
> import matplotlib.pyplot as plt
> import matplotlib.cm as cm
> import mpl_toolkits.axes_grid1 as ag
>
> import numpy as np
>
> fig1 = plt.figure()
>
> grid1 = ag.AxesGrid( fig1, 111, nrows_ncols = (1,2), axes_pad = 0.5)
>
> grid1[0].xaxis.set_label_position('top')
> grid1[0].xaxis.set_label_text('foo')
>
> grid1[1].xaxis.set_label_position('top')
> grid1[1].xaxis.set_label_text('bar')
>
> grid1[0].yaxis.set_label_position('right')
> grid1[0].yaxis.set_label_text('foo')
>
> grid1[1].yaxis.set_label_position('right')
> grid1[1].yaxis.set_label_text('bar')
> grid1[1].yaxis.label.set_visible(True) # tmp workaround
>
>
> fig2 = plt.figure()
> grid2 = ag.AxesGrid( fig2, 111, nrows_ncols = (2,1), axes_pad = 0.5)
>
> grid2[0].xaxis.set_label_position('top')
> grid2[0].xaxis.set_label_text('bar')
> grid2[0].xaxis.label.set_visible(True) # tmp workaround
>
> grid2[1].xaxis.set_label_position('top')
> grid2[1].xaxis.set_label_text('bar')
>
> grid2[0].yaxis.set_label_position('right')
> grid2[0].yaxis.set_label_text('foo')
>
> grid2[1].yaxis.set_label_position('right')
> grid2[1].yaxis.set_label_text('bar')
>
> plt.show()
> #-------------------------------
>
> best,
> --
> Paul Ivanov
> 314 address only used for lists, off-list direct email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAk094eYACgkQe+cmRQ8+KPc/qACePreDR4ThGj/2PttN6OaMXm0K
> 17YAmwbIpf+++7fYVqI3asKiBf8Z3zlT
> =eG7W
> -----END PGP SIGNATURE-----
>
>
> ------------------------------------------------------------------------------
> 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
>
>
-- 
Russell J. Hewett
Ph.D. Candidate
Department of Computer Science
University of Illinois at Urbana-Champaign
www.russellhewett.com
From: Paul I. <piv...@gm...> - 2011年01月24日 21:42:31
C M, on 2011年01月24日 16:27, wrote:
> I looked through the gallery, but didn't see this one and am not sure
> how to create it. It would be a "floating bar chart" (or floating
> column chart), like what is seen here:
> 
> http://peltiertech.com/Excel/pix1/BloodSugarFloater.gif
Hi Che,
just specify the 'bottom' keyword argument to bar. Note that the
second parameter is height of the bar, *not* the top of the bar
plt.bar([1,2,3,4], [2,2.5,5,3], bottom=[0,-1,1,2])
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: C M <cmp...@gm...> - 2011年01月24日 21:27:49
I looked through the gallery, but didn't see this one and am not sure
how to create it. It would be a "floating bar chart" (or floating
column chart), like what is seen here:
http://peltiertech.com/Excel/pix1/BloodSugarFloater.gif
Thanks,
Che
From: Paul I. <piv...@gm...> - 2011年01月24日 21:27:42
Daniel Mader, on 2011年01月24日 20:55, wrote:
> Hi,
> 
> I have seen this ever since I use mpl_toolkits.mplot3d.Axes3D but it never
> bothered me too much until now: the labels are not aligned in paralled to
> the axes so that with longer labels or small figsizes, they run into the
> tick labels, besides looking odd.
 
Hi Daniel,
it does appear like a bug, though only for some views on the
axes, thanks for the report. I'm not very familiar with this
code, so I'll leave the bugfix for someone else, but here's the
temporary workaround:
> Is there anything I can do to change the angle manually?
# prevent the automatic rotation caused by view changes
ax.yaxis.set_rotate_label(False) 
ax.yaxis.label.set_rotation(45)
Beware that you'll have to adjust that angle on a per-view basis
to get things to look right.
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: Paul I. <piv...@gm...> - 2011年01月24日 20:33:38
Russell Hewett, on 2011年01月24日 13:56, wrote:
> Hi All,
> 
> I can't get the x label on the top row of an ImageGrid to display if there
> is more than one row in the grid. I suspect that something is being clipped
> somewhere, but have no idea what to do to fix it. (Note, this also happens
> on the right edge of a ride-sided y axis label.)
> 
> I have included some minimal sample code below. I'd appreciate it if anyone
> can point me in the right direction.
> 
> 
> Cheers,
> Russ
Hi Russ, 
thanks for the report - at a glance, it appears to be a bug in
AxesGrid removing redundant labels for shared axis when they
align. I've included a temporary workaround for your script, but
don't have time to look into it further at the moment. By the
way, calling grid[0].axes is redundant, so I just modified it to
use grid[0].xaxis, which is equivalent.
#-------------------------------
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import mpl_toolkits.axes_grid1 as ag
import numpy as np
fig1 = plt.figure()
grid1 = ag.AxesGrid( fig1, 111, nrows_ncols = (1,2), axes_pad = 0.5)
grid1[0].xaxis.set_label_position('top')
grid1[0].xaxis.set_label_text('foo')
grid1[1].xaxis.set_label_position('top')
grid1[1].xaxis.set_label_text('bar')
grid1[0].yaxis.set_label_position('right')
grid1[0].yaxis.set_label_text('foo')
grid1[1].yaxis.set_label_position('right')
grid1[1].yaxis.set_label_text('bar')
grid1[1].yaxis.label.set_visible(True) # tmp workaround
fig2 = plt.figure()
grid2 = ag.AxesGrid( fig2, 111, nrows_ncols = (2,1), axes_pad = 0.5)
grid2[0].xaxis.set_label_position('top')
grid2[0].xaxis.set_label_text('bar')
grid2[0].xaxis.label.set_visible(True) # tmp workaround
grid2[1].xaxis.set_label_position('top')
grid2[1].xaxis.set_label_text('bar')
grid2[0].yaxis.set_label_position('right')
grid2[0].yaxis.set_label_text('foo')
grid2[1].yaxis.set_label_position('right')
grid2[1].yaxis.set_label_text('bar')
plt.show()
#-------------------------------
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: Russell H. <rhe...@il...> - 2011年01月24日 19:56:16
Hi All,
I can't get the x label on the top row of an ImageGrid to display if there
is more than one row in the grid. I suspect that something is being clipped
somewhere, but have no idea what to do to fix it. (Note, this also happens
on the right edge of a ride-sided y axis label.)
I have included some minimal sample code below. I'd appreciate it if anyone
can point me in the right direction.
Cheers,
Russ
#-------------------------------
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import mpl_toolkits.axes_grid1 as ag
import numpy as np
fig1 = plt.figure()
grid1 = ag.AxesGrid( fig1, 111, nrows_ncols = (1,2), axes_pad = 0.5)
grid1[0].axes.xaxis.set_label_position('top')
grid1[0].axes.xaxis.set_label_text('foo')
grid1[1].axes.xaxis.set_label_position('top')
grid1[1].axes.xaxis.set_label_text('bar')
grid1[0].axes.yaxis.set_label_position('right')
grid1[0].axes.yaxis.set_label_text('foo')
grid1[1].axes.yaxis.set_label_position('right')
grid1[1].axes.yaxis.set_label_text('bar')
fig2 = plt.figure()
grid2 = ag.AxesGrid( fig2, 111, nrows_ncols = (2,1), axes_pad = 0.5)
grid2[0].axes.xaxis.set_label_position('top')
grid2[0].axes.xaxis.set_label_text('bar')
grid2[1].axes.xaxis.set_label_position('top')
grid2[1].axes.xaxis.set_label_text('bar')
grid2[0].axes.yaxis.set_label_position('right')
grid2[0].axes.yaxis.set_label_text('foo')
grid2[1].axes.yaxis.set_label_position('right')
grid2[1].axes.yaxis.set_label_text('bar')
plt.show()
#-------------------------------
-- 
Russell J. Hewett
Ph.D. Candidate
Department of Computer Science
University of Illinois at Urbana-Champaign
www.russellhewett.com
From: Lou P. <lou...@ya...> - 2011年01月24日 18:34:45
I have an installation of Python 2.6.4 on my MacBook Pro (OS X 10.6) that by 
default uses X11 windows and dialogs rather than the Mac version of those GUI 
items. In my googling and exchanges on other support groups I've come down to 
the problem may be with the Tcl/Tk installation using the "generic" X11 GUI 
rather than the Mac version. Does anyone know how I can change that in the Tk 
part of the python framework?
 
I think this problem came up in the iPython email list, but I didn't get enough 
info from the messages there.
 
More Info: The python framework is part of the SAGE package which I installed 
from source. I did this on my Mac Pro (system 10.4) and it works well with Mac 
windows for matplotlib and Mac open/save dialogs for Tk calls. But on my 
MacBook Pro I get X11 windows and dialogs. I want the Mac versions.
 
Even more info:
 
If you're interested, here's the original message I put up on the SAGE support 
group and was told it's a problem with the type of Tcl/Tk installed.
-- Lou Pecora
-----------------------------------------------------------------------------
I have an installation of SAGE (from source) on my Mac laptop in which using the 
tcl/tk library to plot (using TKAgg backend) or call tk file open/save dialogs 
calls the X11 versions and not the native Mac versions of dialogs and windows. 
I want to get the Mac versions.
 
I posted about this on this list recently and now after a response here and much 
googling I have the sense that the problem is that I have a SAGE package with an 
X11 version of the tk library rather than the Mac one. I compiled SAGE from 
source on my Mac laptop. That went perfectly. I don't know how I got the X11 
version since I also compiled SAGE from source on my Mac desktop where the 
plotting and file dialogs are the correct Mac versions, not X11. The only 
difference is that the laptop is Mac OS X 10.6 and the desktop is 10.4. If that 
matters, I don't know.
 
Does anyone know how to get the Mac version installed in the SAGE source-compile 
installation? I have not found an answer to this elsewhere. I'm hoping someone 
here knows how this is done with the source installation.
 
Thanks for any help or pointers.
 
-- Lou Pecora
 
From: Eric F. <ef...@ha...> - 2011年01月24日 18:25:12
On 01/23/2011 11:46 PM, Paul Ivanov wrote:
[...]
> Done in r8935, see examples/pylab_examples/broken_axis.py
>
Thank you.
> I documented the above, used deterministic fake data, as Eric
> suggested, and added the diagonal cut lines that usually
> accompany a broken axis. Here's the tail end of the script which
> creates that effect (see updated attached image).
Beautiful!
Eric
>
> # This looks pretty good, and was fairly painless, but you can
> # get that cut-out diagonal lines look with just a bit more
> # work. The important thing to know here is that in axes
> # coordinates, which are always between 0-1, spine endpoints
> # are at these locations (0,0), (0,1), (1,0), and (1,1). Thus,
> # we just need to put the diagonals in the appropriate corners
> # of each of our axes, and so long as we use the right
> # transform and disable clipping.
>
> d = .015 # how big to make the diagonal lines in axes coordinates
> # arguments to pass plot, just so we don't keep repeating them
> kwargs = dict(transform=ax.transAxes, color='k', clip_on=False)
> ax.plot((-d,+d),(-d,+d), **kwargs) # top-left diagonal
> ax.plot((1-d,1+d),(-d,+d), **kwargs) # top-right diagonal
>
> kwargs.update(transform=ax2.transAxes) # switch to the bottom axes
> ax2.plot((-d,+d),(1-d,1+d), **kwargs) # bottom-left diagonal
> ax2.plot((1-d,1+d),(1-d,1+d), **kwargs) # bottom-right diagonal
>
> # What's cool about this is that now if we vary the distance
> # between ax and ax2 via f.subplots_adjust(hspace=...) or
> # plt.subplot_tool(), the diagonal lines will move accordingly,
> # and stay right at the tips of the spines they are 'breaking'
>
> best,
From: E <pu...@je...> - 2011年01月24日 15:40:50
Hello matplotlib users.
I'm new to signal processing and I've read that RMS could be found from
a PSD. I'm interested in as I would further like to know energy in a
signal through it's frequencies.
My problem is I don't find how to calculate the RMS from the PSD output.
It seems it's a matter of scale (frequencies bandwith is taken in
account already).
I wrote a test case with a simple sinus. I should be able to find the
same RMS value from the PSD method and direct RMS over signal method.
Could you please have a look and tell me how to find good RMS value from
PSD output?
Thanks
#!/usr/bin/python
# -*- coding: utf-8 -*-
import matplotlib, platform
if platform.system() == 'Linux' :
matplotlib.use("gtk")
import pylab
import scipy
## PSD vs RMS
#Parameters
samplerate = 48000
nfft = 1024*2
graph = False
#create 1 sec sinus signal
t = scipy.arange(0, 1 , 1/float(samplerate))
signal = .25*scipy.sin(2*scipy.pi*(samplerate/10.)*t)
print len(signal)
#RMS of an array
def RMS(data):
rms = data**2
rms = scipy.sqrt(rms.sum()/len(data))
return rms
#PSD of an array. I want this to return the RMS
def RMSfromPSD(data) :
y, x = pylab.psd(data, NFFT = nfft, Fs = samplerate)
##Calculate the RMS
#The energy returned by PSD depends on FFT size
freqbandwith = x[1]
y = y*freqbandwith
#The energy returned by PSD depends on Samplerate
y = y/float(samplerate)
#Summing the power in freq domain to get RMS
rms = scipy.sqrt(y.sum())
return rms
print "RMS method", RMS(signal)
print "RMS using PSD method", RMSfromPSD(signal)
#Graph
if graph == True :
pylab.subplot(211)
pylab.plot(t,signal)
pylab.subplot(212)
pylab.psd(signal, nfft, samplerate)
pylab.show()
From: Paul I. <piv...@gm...> - 2011年01月24日 09:47:05
Attachments: broken_axis.png
Eric Firing, on 2011年01月22日 17:49, wrote:
> >> Paul Ivanov, on 2011年01月22日 18:28, wrote:
> 
> Paul,
> 
> Your example below is nice, and this question comes up quite often. If 
> we don't already have a gallery example of this, you might want to add 
> one. (Probably better to use deterministic fake data rather than random.)
> 
> >>
> >> import numpy as np
> >> import matplotlib.pylab as plt
> >> pts = np.random.rand(30)*.2
> >> pts[[7,11]] += .8
> >> f,(ax,ax2) = plt.subplots(2,1,sharex=True)
> >>
> >> ax.plot(pts)
> >> ax2.plot(pts)
> >> ax.set_ylim(.78,1.)
> >> ax2.set_ylim(0,.22)
> >>
> >> ax.xaxis.tick_top()
> >> ax.spines['bottom'].set_visible(False)
> >> ax.tick_params(labeltop='off')
> >> ax2.xaxis.tick_bottom()
> >> ax2.spines['top'].set_visible(False)
Done in r8935, see examples/pylab_examples/broken_axis.py
I documented the above, used deterministic fake data, as Eric
suggested, and added the diagonal cut lines that usually
accompany a broken axis. Here's the tail end of the script which
creates that effect (see updated attached image).
 # This looks pretty good, and was fairly painless, but you can
 # get that cut-out diagonal lines look with just a bit more
 # work. The important thing to know here is that in axes
 # coordinates, which are always between 0-1, spine endpoints
 # are at these locations (0,0), (0,1), (1,0), and (1,1). Thus,
 # we just need to put the diagonals in the appropriate corners
 # of each of our axes, and so long as we use the right
 # transform and disable clipping.
 
 d = .015 # how big to make the diagonal lines in axes coordinates
 # arguments to pass plot, just so we don't keep repeating them
 kwargs = dict(transform=ax.transAxes, color='k', clip_on=False)
 ax.plot((-d,+d),(-d,+d), **kwargs) # top-left diagonal
 ax.plot((1-d,1+d),(-d,+d), **kwargs) # top-right diagonal
 
 kwargs.update(transform=ax2.transAxes) # switch to the bottom axes
 ax2.plot((-d,+d),(1-d,1+d), **kwargs) # bottom-left diagonal
 ax2.plot((1-d,1+d),(1-d,1+d), **kwargs) # bottom-right diagonal
 
 # What's cool about this is that now if we vary the distance
 # between ax and ax2 via f.subplots_adjust(hspace=...) or
 # plt.subplot_tool(), the diagonal lines will move accordingly,
 # and stay right at the tips of the spines they are 'breaking'
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
1 message has been excluded from this view by a project administrator.

Showing 15 results of 15

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 によって変換されたページ (->オリジナル) /