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

Showing 17 results of 17

From: Stephen G. <ste...@op...> - 2007年06月14日 23:21:51
Hi John,
This is absolutely fantastic, does everything I want, 1/2 hr after 
getting to work, I had it up and running in my application.
I do have a question though.
I had not seen mention of SpanSelector before in documentation.
And I do feel confusion about where to find the best documentation.
I look on the web site, and I can see a pylab API 
http://matplotlib.sourceforge.net/pylab_commands.html
I can see another page with MatPlotLib interface 
http://matplotlib.sourceforge.net/matplotlib.pylab.html#-cla
both of which make no mention of SpanSelector
After seeing you use this command I had another look on web site and saw 
a link to API (pdf) http://matplotlib.sourceforge.net/api.pdf
Which does have a section on SpanSelector
I did a search on the Wiki and couldn't find an entry for SpanSelector
On the forums I have heard about an OO interface.
I am Sooo confused where I should go and look for documentation now, 
.... how can I learn little gems like this?, Which interface should I use?
Love using MatPlotLib/pylab, whatever it's called, I've found it quick 
to get something up and running, the forums are great for snippets of info
and I would love to get a deeper understanding of the capabilities of 
this tool.
Thanks
Steve
John Hunter wrote:
> On 6/14/07, steve george <ste...@op...> wrote:
>>
>> WOW - I delayed my bed time when I saw this come in.
>> It certainly seems to do what I want in your example.
>>
>> Tomorrow at work I'll try and fit it into my frame work, and see what
>> happens.
>
> Try setting the useblit=True parameter in the SpanSelector -- you'll
> get much better responsiveness. I accidentally left it off in the
> code I posted.
>
> JDH
>
 
From: jkitchin <jki...@an...> - 2007年06月14日 22:20:32
This great! Thanks for the speedy response. I will have to try this out on a
large dataset. 
I have already seen an issue when clicking near two points that are close
together, then the browser selects both points. but the key browsing helps
alot to get around that. This is a great starting point for our analysis
though. Thanks again.
John Hunter-4 wrote:
> 
> On 6/14/07, jkitchin <jki...@an...> wrote:
>>
>> I just learned about the (new?) picker features in matplotlib. That is a
>> fantastic development!
>> Someone else mentioned about having a problem though when the points are
>> clustered together, which brings me to my question:
>>
>> Is there a way to "browse" through the data points using the tab key?
>> What I
>> envision is that a particular point would have a "focus" because it had
>> previously been picked, and then you would press a key (such as tab) and
>> it
>> would move the focus to another point, in essence picking another point
>> in
>> the data set.
>>
> 
> The TAB key is a little problematic, because it is already used by
> some GUI toolkits, but this kind of thing is fairly easy to do. MPL
> gives you access to the button press events, key press events, etc, so
> all you have to do is connect up the callbacks to what you want your
> figure to do.
> 
> Here is an example of a "data browser" which uses 'n' and 'p' to move
> through the next and previous points after a mouse select.
> 
> import numpy as npy
> from pylab import figure, show
> 
> 
> X = npy.random.rand(100, 200)
> xs = npy.mean(X, axis=1)
> ys = npy.std(X, axis=1)
> 
> fig = figure()
> ax = fig.add_subplot(211)
> ax.set_title('click on point to plot time series')
> line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance
> ax2 = fig.add_subplot(212)
> 
> class PointBrowser:
> """
> Click on a point to select and highlight it -- the data that
> generated the point will be shown in the lower axes. Use the 'n'
> and 'p' keys to browse through the next and pervious points
> """
> def __init__(self):
> self.lastind = 0
> 
> self.text = ax.text(0.05, 0.95, 'selected: none',
> transform=ax.transAxes, va='top')
> self.selected, = ax.plot([xs[0]], [ys[0]], 'o', ms=12, alpha=0.4,
> color='yellow', visible=False)
> 
> def onpress(self, event):
> if self.lastind is None: return
> if event.key not in ('n', 'p'): return
> if event.key=='n': inc = 1
> else: inc = -1
> 
> 
> self.lastind += inc
> self.lastind = npy.clip(self.lastind, 0, len(xs)-1)
> self.update()
> 
> def onpick(self, event):
> 
> if event.artist!=line: return True
> 
> N = len(event.ind)
> if not N: return True
> 
> # the click locations
> x = event.mouseevent.xdata
> y = event.mouseevent.ydata
> 
> 
> distances = npy.hypot(x-xs[event.ind], y-ys[event.ind])
> indmin = distances.argmin()
> dataind = event.ind[indmin]
> 
> self.lastind = dataind
> self.update()
> 
> def update(self):
> if self.lastind is None: return
> 
> dataind = self.lastind
> 
> ax2.cla()
> ax2.plot(X[dataind])
> 
> ax2.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind],
> ys[dataind]),
> transform=ax2.transAxes, va='top')
> ax2.set_ylim(-0.5, 1.5)
> self.selected.set_visible(True)
> self.selected.set_data(xs[dataind], ys[dataind])
> 
> self.text.set_text('selected: %d'%dataind)
> fig.canvas.draw()
> 
> 
> browser = PointBrowser()
> 
> fig.canvas.mpl_connect('pick_event', browser.onpick)
> fig.canvas.mpl_connect('key_press_event', browser.onpress)
> 
> show()
> 
> 
>> Can that be done in a straight-forward way? Thanks,
>>
>> j
>> --
>> View this message in context:
>> http://www.nabble.com/plot-data-point-browsing-tf3922973.html#a11124244
>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> 
> import numpy as npy
> from pylab import figure, show
> 
> 
> X = npy.random.rand(100, 200)
> xs = npy.mean(X, axis=1)
> ys = npy.std(X, axis=1)
> 
> fig = figure()
> ax = fig.add_subplot(211)
> ax.set_title('click on point to plot time series')
> line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance
> ax2 = fig.add_subplot(212)
> 
> class PointBrowser:
> """
> Click on a point to select and highlight it -- the data that
> generated the point will be shown in the lower axes. Use the 'n'
> and 'p' keys to browse through the next and pervious points
> """
> def __init__(self):
> self.lastind = 0
> 
> self.text = ax.text(0.05, 0.95, 'selected: none',
> transform=ax.transAxes, va='top')
> self.selected, = ax.plot([xs[0]], [ys[0]], 'o', ms=12, alpha=0.4,
> color='yellow', visible=False)
> 
> def onpress(self, event):
> if self.lastind is None: return
> if event.key not in ('n', 'p'): return
> if event.key=='n': inc = 1
> else: inc = -1
> 
> 
> self.lastind += inc
> self.lastind = npy.clip(self.lastind, 0, len(xs)-1)
> self.update()
> 
> def onpick(self, event):
> 
> if event.artist!=line: return True
> 
> N = len(event.ind)
> if not N: return True
> 
> # the click locations
> x = event.mouseevent.xdata
> y = event.mouseevent.ydata
> 
> 
> distances = npy.hypot(x-xs[event.ind], y-ys[event.ind])
> indmin = distances.argmin()
> dataind = event.ind[indmin]
> 
> self.lastind = dataind
> self.update()
> 
> def update(self):
> if self.lastind is None: return
> 
> dataind = self.lastind
> 
> ax2.cla()
> ax2.plot(X[dataind])
> 
> ax2.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind],
> ys[dataind]),
> transform=ax2.transAxes, va='top')
> ax2.set_ylim(-0.5, 1.5)
> self.selected.set_visible(True)
> self.selected.set_data(xs[dataind], ys[dataind])
> 
> self.text.set_text('selected: %d'%dataind)
> fig.canvas.draw()
> 
> 
> browser = PointBrowser()
> 
> fig.canvas.mpl_connect('pick_event', browser.onpick)
> fig.canvas.mpl_connect('key_press_event', browser.onpress)
> 
> show()
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://www.nabble.com/plot-data-point-browsing-tf3922973.html#a11129890
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Brian <fo...@gm...> - 2007年06月14日 19:31:55
Hello,
I have been using MPL 0.90.0 without trouble for some time. I do not use
any interactive backends and simply savefig to a pdf which my viewer updates
when the file is written to. This has worked very well for me until I just
tried to upgrade to MPL 0.90.1. I am running on G4 powerbook using fink for
python 2.5 and some other dependencies. The following code works fine
in MPL 0.90.0 and gives the error message below on MPL 0.90.1:
[code]
import matplotlib
matplotlib.use('PDF')
import numpy
import pylab as p
x = 2.*numpy.pi*numpy.arange(1000)/250.
y = numpy.sin(x)
plt = p.plot(x,y,'r')
p.savefig('test.pdf')
[/code]
[traceback]
---------------------------------------------------------------------------
<type 'exceptions.AttributeError'> Traceback (most recent call last)
/<ipython console> in <module>()
/sw/lib/python2.5/site-packages/matplotlib/pylab.py in savefig(*args,
**kwargs)
 794 def savefig(*args, **kwargs):
 795 fig = gcf()
--> 796 return fig.savefig(*args, **kwargs)
 797 if Figure.savefig.__doc__ is not None:
 798 savefig.__doc__ = dedent(Figure.savefig.__doc__)
/sw/lib/python2.5/site-packages/matplotlib/figure.py in savefig(self, *args,
**kwargs)
 757 kwargs[key] = rcParams['savefig.%s'%key]
 758
--> 759 self.canvas.print_figure(*args, **kwargs)
 760
 761 def colorbar(self, mappable, cax=None, **kw):
/sw/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py in
print_figure(self, filename, dpi, facecolor, edgecolor, orientation,
**kwargs)
 186 try:
 187 agg.print_figure(filename, dpi, facecolor, edgecolor,
orientation,
--> 188 **kwargs)
 189 except:
 190 self.figure.set_canvas(self)
/sw/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py in
print_figure(self, filename, dpi, facecolor, edgecolor, orientation,
**kwargs)
 495 if printfunc is not None:
 496 try:
--> 497 printfunc(filename, dpi, facecolor, edgecolor,
orientation, **kwargs)
 498 except:
 499 # restore the original figure properties
/sw/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py in
print_figure(self, filename, dpi, facecolor, edgecolor, orientation,
**kwargs)
 1393 self.figure.draw(renderer)
 1394 renderer.finalize()
-> 1395 file.close()
 1396
 1397 class FigureManagerPdf(FigureManagerBase):
/sw/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py in
close(self)
 399 # objects
 400 self.endStream()
--> 401 self.writeFonts()
 402 self.writeObject(self.alphaStateObject,
 403 dict([(val[0], val[1])
/sw/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py in
writeFonts(self)
 454 fontdictObject = self._write_afm_font(filename)
 455 else:
--> 456 fontdictObject = self.embedTTF(filename)
 457 fonts[Fx] = fontdictObject
 458 #print >>sys.stderr, filename
/sw/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py in
embedTTF(self, filename)
 506 width = font.load_char(unicode,
flags=LOAD_NO_SCALE).horiAdvance
 507 return cvt(width)
--> 508 widths = [ get_char_width(charcode) for charcode in
range(firstchar, lastchar+1) ]
 509
 510 widthsObject = self.reserveObject('font widths')
/sw/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py in
get_char_width(charcode)
 503 firstchar, lastchar = 0, 255
 504 def get_char_width(charcode):
--> 505 unicode = cp1252.decoding_map[charcode] or 0
 506 width = font.load_char(unicode,
flags=LOAD_NO_SCALE).horiAdvance
 507 return cvt(width)
<type 'exceptions.AttributeError'>: 'module' object has no attribute
'decoding_map'
[/traceback]
Any help would be great!
-Brian
From: John H. <jd...@gm...> - 2007年06月14日 17:23:49
Attachments: pick_event_demo3.py
On 6/14/07, jkitchin <jki...@an...> wrote:
>
> I just learned about the (new?) picker features in matplotlib. That is a
> fantastic development!
> Someone else mentioned about having a problem though when the points are
> clustered together, which brings me to my question:
>
> Is there a way to "browse" through the data points using the tab key? What I
> envision is that a particular point would have a "focus" because it had
> previously been picked, and then you would press a key (such as tab) and it
> would move the focus to another point, in essence picking another point in
> the data set.
>
The TAB key is a little problematic, because it is already used by
some GUI toolkits, but this kind of thing is fairly easy to do. MPL
gives you access to the button press events, key press events, etc, so
all you have to do is connect up the callbacks to what you want your
figure to do.
Here is an example of a "data browser" which uses 'n' and 'p' to move
through the next and previous points after a mouse select.
import numpy as npy
from pylab import figure, show
X = npy.random.rand(100, 200)
xs = npy.mean(X, axis=1)
ys = npy.std(X, axis=1)
fig = figure()
ax = fig.add_subplot(211)
ax.set_title('click on point to plot time series')
line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance
ax2 = fig.add_subplot(212)
class PointBrowser:
 """
 Click on a point to select and highlight it -- the data that
 generated the point will be shown in the lower axes. Use the 'n'
 and 'p' keys to browse through the next and pervious points
 """
 def __init__(self):
 self.lastind = 0
 self.text = ax.text(0.05, 0.95, 'selected: none',
 transform=ax.transAxes, va='top')
 self.selected, = ax.plot([xs[0]], [ys[0]], 'o', ms=12, alpha=0.4,
 color='yellow', visible=False)
 def onpress(self, event):
 if self.lastind is None: return
 if event.key not in ('n', 'p'): return
 if event.key=='n': inc = 1
 else: inc = -1
 self.lastind += inc
 self.lastind = npy.clip(self.lastind, 0, len(xs)-1)
 self.update()
 def onpick(self, event):
 if event.artist!=line: return True
 N = len(event.ind)
 if not N: return True
 # the click locations
 x = event.mouseevent.xdata
 y = event.mouseevent.ydata
 distances = npy.hypot(x-xs[event.ind], y-ys[event.ind])
 indmin = distances.argmin()
 dataind = event.ind[indmin]
 self.lastind = dataind
 self.update()
 def update(self):
 if self.lastind is None: return
 dataind = self.lastind
 ax2.cla()
 ax2.plot(X[dataind])
 ax2.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
 transform=ax2.transAxes, va='top')
 ax2.set_ylim(-0.5, 1.5)
 self.selected.set_visible(True)
 self.selected.set_data(xs[dataind], ys[dataind])
 self.text.set_text('selected: %d'%dataind)
 fig.canvas.draw()
browser = PointBrowser()
fig.canvas.mpl_connect('pick_event', browser.onpick)
fig.canvas.mpl_connect('key_press_event', browser.onpress)
show()
> Can that be done in a straight-forward way? Thanks,
>
> j
> --
> View this message in context: http://www.nabble.com/plot-data-point-browsing-tf3922973.html#a11124244
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: jkitchin <jki...@an...> - 2007年06月14日 16:54:51
I just learned about the (new?) picker features in matplotlib. That is a
fantastic development! 
Someone else mentioned about having a problem though when the points are
clustered together, which brings me to my question:
Is there a way to "browse" through the data points using the tab key? What I
envision is that a particular point would have a "focus" because it had
previously been picked, and then you would press a key (such as tab) and it
would move the focus to another point, in essence picking another point in
the data set. 
Can that be done in a straight-forward way? Thanks,
j
-- 
View this message in context: http://www.nabble.com/plot-data-point-browsing-tf3922973.html#a11124244
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Alexandre B. <ale...@gm...> - 2007年06月14日 16:02:58
Hi all,
I'm trying to make my own matplotlib back-end using FigureFrameWx,
FigureManagerWx, FigureCanvasWx.
My problem is that when i use the NavigationToolbar2Wx for scrolling the
axes values, my graph is updates but the values of the axes are not. The
consequence are visible on this picture :
http://dl.free.fr/RHWELK1d/bug.png. The only way that I have found for
refreshing all the figure is to resize
the window...
I have tried to correct the bug but without success. I know that the
scrolling of the toolbar uses the dynamic_update method that call the
canvas.draw method. I have seen a note at the beginning of the backend_wx.py
file :
Fixed this release:
>
Bug #866969: Dynamic update does not function with backend_wx [JOD]
I don't now if there is any link with my problem... So do you have an idea
of the problem ?
I am using matplotlib 0.90.1 with python 2.4.
Thank you for your answers
From: John H. <jd...@gm...> - 2007年06月14日 14:46:24
On 6/14/07, steve george <ste...@op...> wrote:
>
> WOW - I delayed my bed time when I saw this come in.
> It certainly seems to do what I want in your example.
>
> Tomorrow at work I'll try and fit it into my frame work, and see what
> happens.
Try setting the useblit=True parameter in the SpanSelector -- you'll
get much better responsiveness. I accidentally left it off in the
code I posted.
JDH
From: Werner F. B. <wer...@fr...> - 2007年06月14日 14:15:32
John,
John Hunter wrote:
> On 6/14/07, Werner F. Bruhin <wer...@fr...> wrote:
>
>> >>> I am getting this:
>> >>> Could not match Bitstream Vera Serif, New Century Schoolbook, 
>> Century
>> >>> Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, 
>> Times
>> >>> New Roman, Times, Palatino, Charter, serif, normal, normal. 
>> Returning
>> >>> C:\Python25\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf
>> Is there any solution to the above issue yet?
>
>
> In your earlier post in this thread you said:
>
>> Works the first time after I removed the cache file. Looking at the
>> file it might have something to do with Unicode, i.e. one of the two "/"
>> is encoded as 'u0005C', see attached file.
>
> I thought that removing the cache file and rerunning fixed our
> problem. What am I missing?
It "fixes it" only for the current run. If I stop and start the 
program, i.e. use the newly build cache file I see the same problem again.
For the moment I work around it by just setting verbose to silent.
Best regards
Werner
From: steve g. <ste...@op...> - 2007年06月14日 14:15:00
WOW - I delayed my bed time when I saw this come in.
It certainly seems to do what I want in your example.
Tomorrow at work I'll try and fit it into my frame work, and see what 
happens.
Thanks a lot,
Steve
John Hunter wrote:
> On 6/14/07, Stephen George <ste...@op...> wrote:
>
>> So my questions.
>> 1) Is there a way to get the indexes (not the values) of the portion of
>> the line actually showing on screen
>> 2) Is there a way to get a copy of the portion of the data displayed on
>> screen (in a new array) ?
>> 3) Is there a better way of linking psd so it performs the spectrum
>> analysis only on the portion of data on screen?
>
> I just updated the span selector example in svn to show you how to do
> this. You select a region in the upper graph with a mouse drag, and
> it plots the detail of the selected region in the lower graph. You
> should be able to modify this to plot the psd of the selected region,
> etc....
>
> #!/usr/bin/env python
> """
> The SpanSelector is a mouse widget to select a xmin/xmax range and 
> plot the
> detail view of the selected region in the lower axes
> """
> import numpy as npy
> from pylab import figure, show
> from matplotlib.widgets import SpanSelector
>
> fig = figure(figsize=(8,6))
> ax = fig.add_subplot(211, axisbg='#FFFFCC')
>
> x = npy.arange(0.0, 5.0, 0.01)
> y = npy.sin(2*npy.pi*x) + 0.5*npy.random.randn(len(x))
>
> ax.plot(x, y, '-')
> ax.set_ylim(-2,2)
> ax.set_title('Press left mouse button and drag to test')
>
> ax2 = fig.add_subplot(212, axisbg='#FFFFCC')
> line2, = ax2.plot(x, y, '-')
>
>
> def onselect(xmin, xmax):
> indmin, indmax = npy.searchsorted(x, (xmin, xmax))
> indmax = min(len(x)-1, indmax)
>
> thisx = x[indmin:indmax]
> thisy = y[indmin:indmax]
> line2.set_data(thisx, thisy)
> ax2.set_xlim(thisx[0], thisx[-1])
> ax2.set_ylim(thisy.min(), thisy.max())
> fig.canvas.draw()
>
> # set useblit True on gtkagg for enhanced performance
> span = SpanSelector(ax, onselect, 'horizontal', useblit=False,
> rectprops=dict(alpha=0.5, facecolor='red') )
>
>
> show()
>
>>
>> *
>> *Thanks for your help
>> Steve
>>
>> ------------------------------------------------------------------------- 
>>
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> ------------------------------------------------------------------------
>
> #!/usr/bin/env python
> """
> The SpanSelector is a mouse widget to select a xmin/xmax range and plot the
> detail view of the selected region in the lower axes
> """
> import numpy as npy
> from pylab import figure, show
> from matplotlib.widgets import SpanSelector
>
> fig = figure(figsize=(8,6))
> ax = fig.add_subplot(211, axisbg='#FFFFCC')
>
> x = npy.arange(0.0, 5.0, 0.01)
> y = npy.sin(2*npy.pi*x) + 0.5*npy.random.randn(len(x))
>
> ax.plot(x, y, '-')
> ax.set_ylim(-2,2)
> ax.set_title('Press left mouse button and drag to test')
>
> ax2 = fig.add_subplot(212, axisbg='#FFFFCC')
> line2, = ax2.plot(x, y, '-')
>
>
> def onselect(xmin, xmax):
> indmin, indmax = npy.searchsorted(x, (xmin, xmax))
> indmax = min(len(x)-1, indmax)
>
> thisx = x[indmin:indmax]
> thisy = y[indmin:indmax]
> line2.set_data(thisx, thisy)
> ax2.set_xlim(thisx[0], thisx[-1])
> ax2.set_ylim(thisy.min(), thisy.max())
> fig.canvas.draw()
>
> # set useblit True on gtkagg for enhanced performance
> span = SpanSelector(ax, onselect, 'horizontal', useblit=False,
> rectprops=dict(alpha=0.5, facecolor='red') )
>
>
> show()
> 
From: John H. <jd...@gm...> - 2007年06月14日 13:36:18
On 6/14/07, Chris Fonnesbeck <Chr...@my...> wrote:
> I have a strange problem with my builds of matplotlib on OS X 10.4: If I
> install them from the command line, with setup.py, they install fine and
> matplotlib can be imported with no problem. However, I need to build
> distributable OS X packages, which I do using bdist_mpkg; when this package
> is installed, I get an error when importing pylab:
Is there any chance that you are testing in a directory in which a
directory named "matplotlib" exists, but that matplotlib is not your
install directory?
JDH
From: Chris F. <Chr...@My...> - 2007年06月14日 13:34:16
I have a strange problem with my builds of matplotlib on OS X 10.4: If I
install them from the command line, with setup.py, they install fine and
matplotlib can be imported with no problem. However, I need to build
distributable OS X packages, which I do using bdist_mpkg; when this package
is installed, I get an error when importing pylab:
>>> from pylab import *
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib
/python2.5/site-packages/pylab.py", line 1, in <module>
 from matplotlib.pylab import *
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib
/python2.5/site-packages/matplotlib/pylab.py", line 199, in <module>
 import cm
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib
/python2.5/site-packages/matplotlib/cm.py", line 5, in <module>
 import colors
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib
/python2.5/site-packages/matplotlib/colors.py", line 38, in <module>
 from numerix import array, arange, take, put, Float, Int, putmask, \
 File "/Library/Frameworks/Python.framework/Versions/2.5/lib
/python2.5/site-packages/matplotlib/numerix/__init__.py", line 20, in
<module>
 from matplotlib import rcParams, verbose
ImportError: cannot import name rcParams
I would appreciate any help to resolve this issue.
-- 
Christopher J. Fonnesbeck
Population Ecologist, Marine Mammal Section
Fish & Wildlife Research Institute (FWC)
St. Petersburg, FL
Adjunct Assistant Professor
Warnell School of Forestry and Natural Resources
University of Georgia
Athens, GA
T: 727.235.5570
E: Chris dot Fonnesbeck at MyFWC dot com
From: John H. <jd...@gm...> - 2007年06月14日 13:31:30
Attachments: span_selector.py
On 6/14/07, Stephen George <ste...@op...> wrote:
> So my questions.
> 1) Is there a way to get the indexes (not the values) of the portion of
> the line actually showing on screen
> 2) Is there a way to get a copy of the portion of the data displayed on
> screen (in a new array) ?
> 3) Is there a better way of linking psd so it performs the spectrum
> analysis only on the portion of data on screen?
I just updated the span selector example in svn to show you how to do
this. You select a region in the upper graph with a mouse drag, and
it plots the detail of the selected region in the lower graph. You
should be able to modify this to plot the psd of the selected region,
etc....
#!/usr/bin/env python
"""
The SpanSelector is a mouse widget to select a xmin/xmax range and plot the
detail view of the selected region in the lower axes
"""
import numpy as npy
from pylab import figure, show
from matplotlib.widgets import SpanSelector
fig = figure(figsize=(8,6))
ax = fig.add_subplot(211, axisbg='#FFFFCC')
x = npy.arange(0.0, 5.0, 0.01)
y = npy.sin(2*npy.pi*x) + 0.5*npy.random.randn(len(x))
ax.plot(x, y, '-')
ax.set_ylim(-2,2)
ax.set_title('Press left mouse button and drag to test')
ax2 = fig.add_subplot(212, axisbg='#FFFFCC')
line2, = ax2.plot(x, y, '-')
def onselect(xmin, xmax):
 indmin, indmax = npy.searchsorted(x, (xmin, xmax))
 indmax = min(len(x)-1, indmax)
 thisx = x[indmin:indmax]
 thisy = y[indmin:indmax]
 line2.set_data(thisx, thisy)
 ax2.set_xlim(thisx[0], thisx[-1])
 ax2.set_ylim(thisy.min(), thisy.max())
 fig.canvas.draw()
# set useblit True on gtkagg for enhanced performance
span = SpanSelector(ax, onselect, 'horizontal', useblit=False,
 rectprops=dict(alpha=0.5, facecolor='red') )
show()
>
> *
> *Thanks for your help
> Steve
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Chris F. <Chr...@My...> - 2007年06月14日 13:18:39
I have a strange problem with my builds of matplotlib on OS X 10.4: If I
install them from the command line, with setup.py, they install fine and
matplotlib can be imported with no problem. However, I need to build
distributable OS X packages, which I do using bdist_mpkg; when this package
is installed, I get an error when importing pylab:
>>> from pylab import *
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/pylab.py",
line 1, in <module>
 from matplotlib.pylab import *
 File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/pylab.py",
line 199, in <module>
 import cm
 File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/cm.py",
line 5, in <module>
 import colors
 File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/colors.py",
line 38, in <module>
 from numerix import array, arange, take, put, Float, Int, putmask, \
 File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/numerix/__init__.py",
line 20, in <module>
 from matplotlib import rcParams, verbose
ImportError: cannot import name rcParams
I would appreciate any help to resolve this issue.
From: John H. <jd...@gm...> - 2007年06月14日 13:15:32
On 6/14/07, Werner F. Bruhin <wer...@fr...> wrote:
> >>> I am getting this:
> >>> Could not match Bitstream Vera Serif, New Century Schoolbook, Century
> >>> Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times
> >>> New Roman, Times, Palatino, Charter, serif, normal, normal. Returning
> >>> C:\Python25\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf
> Is there any solution to the above issue yet?
In your earlier post in this thread you said:
> Works the first time after I removed the cache file. Looking at the
> file it might have something to do with Unicode, i.e. one of the two "/"
> is encoded as 'u0005C', see attached file.
I thought that removing the cache file and rerunning fixed our
problem. What am I missing?
JDH
From: Werner F. B. <wer...@fr...> - 2007年06月14日 09:41:01
Hi John,
Werner F. Bruhin wrote:
> John,
>
> John Hunter wrote:
>> On 6/4/07, Werner F. Bruhin <wer...@fr...> wrote:
>>> John Hunter wrote:
>>> > matplotlib 0.90.1 is out and available for download from the 
>>> sourceforge site.
>>> >
>>> Just installed it. Works very nicely with the exception of some font
>>> issue.
>>>
>>> I am getting this:
>>> Could not match Bitstream Vera Serif, New Century Schoolbook, Century
>>> Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times
>>> New Roman, Times, Palatino, Charter, serif, normal, normal. Returning
>>> C:\Python25\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf
Is there any solution to the above issue yet?
Best regards
Werner
From: <bre...@un...> - 2007年06月14日 06:06:59
Just as a general comment - perhaps not useful in your case - we have the 
same sort of requirement and find the periodogram facility (specgram) in 
pylab very useful for showing the change in PSD over time - highlighting 
resonances and how they vary in proportion to other functions of time 
(plotted on sub-graphs).
Stephen George <ste...@op...> 
Sent by: mat...@li...
14/06/2007 03:52 PM
To
matplotlib <Mat...@li...>
cc
Subject
[Matplotlib-users] get_xlim() - where am I going wrong
Hi,
I have 2 graphs on one figure.
Graph one - subplot(2,1,1) velocities vs ( Time or SampleIndex) 
depending in input args
Graph two - subplot(2,1,2) psd() - power spectrum to help us find the 
resonances in velocities
As system goes through a number of different states, the resonances 
change during the cycle, so I need to zoomIn GraphOne to an area of 
interest, then re-calc the power spectrum on that portion of data only.
I have something that works in the xaxis=SampleIndex scenario, but fails 
in the xaxis=Time scenario, I am wondering if I am going about it the 
right way.
The following page has 4 graphs that show what I have working now (2 
graphs of velocity vs SampleNo), and the failing case (2 graphs of 
Velocity Vs Time)
*http://tinyurl.com/2xpyly
*
I'll describe what I got.
I connected my function RecalcPowerSpectrum to ReleaseButton event
 pylab.connect( 'button_release_event', RecalcPowerSpectrum)
It's ugly and crude, but if GraphOne is a velocity vs sampleIndex, the 
following works.
My issues start when you look at how I am slicing (if thats the right 
word) the array I pass into psd() and where those values come from.
def RecalcPowerSpectrum( event ): 
 global myAxis
 global lastXstart
 global lastXend
 xlim = myAxis.get_xlim()
 xstart = int(xlim[0])
 xend = int(xlim[1])
 
 if xstart != lastXstart or xend != lastXend:
 print '%s event detected, re-calc power spectrum' % event.name
 lastXstart, lastXend = xstart, xend
 lastXlimits = xlim
 print 'xlim1 =', xstart
 print 'xlim2 =', xend 
 pylab.cla()
 if secondGraph == 'fft':# (plot UDR1 points)
 Fs = 2 * targetvel
 fftdata = pylab.psd(vel[2*xstart:2*xend], NFFT=winsize, 
Fs=Fs, detrend=pylab.mlab.detrend_linear, 
window=pylab.mlab.window_hanning, noverlap=overlap)
 else: #must be a fft2 (plot UDR2 points)
 Fs = targetvel
 fftdata = pylab.psd(combined[xstart:xend], NFFT=winsize, 
Fs=Fs, detrend=pylab.mlab.detrend_linear, 
window=pylab.mlab.window_hanning, noverlap=overlap)
This fails when I run my program to plot with xaxis in time as the 
values returned by get_xlim() are small (0.46408074411240841, 
0.53334652681575301), once I int() these values they are both 0
Clearly I am trying to work with the wrong values. I actually want to 
get the indexes of these values. So I can pass the proper slice of the 
original array into the psd function.
So my questions.
1) Is there a way to get the indexes (not the values) of the portion of 
the line actually showing on screen
2) Is there a way to get a copy of the portion of the data displayed on 
screen (in a new array) ?
3) Is there a better way of linking psd so it performs the spectrum 
analysis only on the portion of data on screen?
*
*Thanks for your help
Steve
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-users mailing list
Mat...@li...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
UNITED GROUP
This email message is the property of United Group. The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, you may not disclose, copy or distribute this email, nor take or omit to take any action in reliance on it. United Group accepts no liability for any damage caused by this email or any attachments due to viruses, interference, interception, corruption or unauthorised access.
If you have received this email in error, please notify United Group immediately by email to the sender's email address and delete this document.
From: Stephen G. <ste...@op...> - 2007年06月14日 05:52:37
Hi,
I have 2 graphs on one figure.
Graph one - subplot(2,1,1) velocities vs ( Time or SampleIndex) 
depending in input args
Graph two - subplot(2,1,2) psd() - power spectrum to help us find the 
resonances in velocities
As system goes through a number of different states, the resonances 
change during the cycle, so I need to zoomIn GraphOne to an area of 
interest, then re-calc the power spectrum on that portion of data only.
I have something that works in the xaxis=SampleIndex scenario, but fails 
in the xaxis=Time scenario, I am wondering if I am going about it the 
right way.
The following page has 4 graphs that show what I have working now (2 
graphs of velocity vs SampleNo), and the failing case (2 graphs of 
Velocity Vs Time)
*http://tinyurl.com/2xpyly
*
I'll describe what I got.
I connected my function RecalcPowerSpectrum to ReleaseButton event
 pylab.connect( 'button_release_event', RecalcPowerSpectrum)
It's ugly and crude, but if GraphOne is a velocity vs sampleIndex, the 
following works.
My issues start when you look at how I am slicing (if thats the right 
word) the array I pass into psd() and where those values come from.
def RecalcPowerSpectrum( event ): 
 global myAxis
 global lastXstart
 global lastXend
 xlim = myAxis.get_xlim()
 xstart = int(xlim[0])
 xend = int(xlim[1])
 
 if xstart != lastXstart or xend != lastXend:
 print '%s event detected, re-calc power spectrum' % event.name
 lastXstart, lastXend = xstart, xend
 lastXlimits = xlim
 print 'xlim1 =', xstart
 print 'xlim2 =', xend 
 pylab.cla()
 if secondGraph == 'fft':# (plot UDR1 points)
 Fs = 2 * targetvel
 fftdata = pylab.psd(vel[2*xstart:2*xend], NFFT=winsize, 
Fs=Fs, detrend=pylab.mlab.detrend_linear, 
window=pylab.mlab.window_hanning, noverlap=overlap)
 else: #must be a fft2 (plot UDR2 points)
 Fs = targetvel
 fftdata = pylab.psd(combined[xstart:xend], NFFT=winsize, 
Fs=Fs, detrend=pylab.mlab.detrend_linear, 
window=pylab.mlab.window_hanning, noverlap=overlap)
This fails when I run my program to plot with xaxis in time as the 
values returned by get_xlim() are small (0.46408074411240841, 
0.53334652681575301), once I int() these values they are both 0
Clearly I am trying to work with the wrong values. I actually want to 
get the indexes of these values. So I can pass the proper slice of the 
original array into the psd function.
So my questions.
1) Is there a way to get the indexes (not the values) of the portion of 
the line actually showing on screen
2) Is there a way to get a copy of the portion of the data displayed on 
screen (in a new array) ?
3) Is there a better way of linking psd so it performs the spectrum 
analysis only on the portion of data on screen?
*
*Thanks for your help
Steve

Showing 17 results of 17

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