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) |
We would like to provide a Matplotlib-like plotting function in a Java application we are building. We can't require our users to install native code so we can't use Matplotlib. We have a simple implementation that would be sufficient for v1.0 of our application that uses jython and jfreechart. To re-implement the whole of Matplotlib would require a collaborative effort and would take a while. You have to start somewhere though so I thought I should post here to ask for advice. Does anyone have any comments or suggestions? Thanks, Duncan
On 6/17/07, Werner F. Bruhin <wer...@fr...> wrote: > > Hi, > > Viraj Vajratkar wrote: > > Hi... thanks a lot for replying... but it would be great if you could > > send me your complete setup.py file... thanks a lot in advance... > Attached is a setup.py and the corresponding the matplotlib example > > Werner > > # -*- coding: iso-8859-1 -*-# > from distutils.core import setup > import os > from os.path import join > import shutil > > import glob > import py2exe > from py2exe.build_exe import py2exe > import sys > > import matplotlib as mp > matplotlib_font_afm = glob.glob(os.sep.join([mp.get_data_path(), > 'fonts/afm/*'])) > matplotlib_font_pdfcorefonts = glob.glob(os.sep.join([mp.get_data_path(), > 'fonts/pdfcorefonts/*'])) > matplotlib_font_ttf = glob.glob(os.sep.join([mp.get_data_path(), > 'fonts/ttf/*'])) > matplotlib_images = glob.glob(os.sep.join([mp.get_data_path(), > 'images/*'])) > > # following should not be needed as of py2exe 0.6.6 > ### cleanup dist and build directory first (for new py2exe version) > ##if os.path.exists("dist/prog"): > ## shutil.rmtree("dist/prog") > ## > ##if os.path.exists("dist/lib"): > ## shutil.rmtree("dist/lib") > ## > ##if os.path.exists("build"): > ## shutil.rmtree("build") > ## > > # > # A program using wxPython > > # The manifest will be inserted as resource into the .exe. This > # gives the controls the Windows XP appearance (if run on XP ;-) > # > manifest_template = ''' > <?xml version="1.0" encoding="UTF-8" standalone="yes"?> > <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> > <assemblyIdentity > version="5.0.0.0" > processorArchitecture="x86" > name="%(prog)s" > type="win32" > /> > <description>%(prog)s</description> > <dependency> > <dependentAssembly> > <assemblyIdentity > type="win32" > name="Microsoft.Windows.Common-Controls" > version="6.0.0.0" > processorArchitecture="X86" > publicKeyToken="6595b64144ccf1df" > language="*" > /> > </dependentAssembly> > </dependency> > <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> > <security> > <requestedPrivileges> > <requestedExecutionLevel > level="AsInvoker" > uiAccess="false"/> > </requestedPrivileges> > </security> > </trustInfo> > </assembly> > ''' > > RT_MANIFEST = 32 > # > > # options for py2exe > options = {"py2exe": {"compressed": 1, > "optimize": 2, > "packages": ["encodings", > "pytz", "matplotlib.numerix", > ], > "excludes": ["MySQLdb", "Tkconstants", "Tkinter", > "tcl" > ], > "dll_excludes": ["tcl84.dll", "tk84.dll", > "wxmsw26uh_vc.dll"] > } > } > zipfile = r"lib\library.zip" > > class MetaBase: > def __init__(self, **kw): > self.__dict__.update(kw) > self.version = '1.0' > self.author = "yourname" > self.author_email = "na...@wh..." > self.company_name = "" > self.copyright = "2003 - 2007 by whoever" > self.url = "http://www.whatever.com/" > self.download_url = "http://www.whatever.com/en/" > self.trademark = "" > self.comments = "a comment on the prog" > self.name = "the prog name" > self.description = "a desc on the prog" > > wx_emb = MetaBase( > script = "embedding_in_wx.py", > other_resources = [(RT_MANIFEST, 1, manifest_template % > dict(prog="your prog name"))], > ## icon_resources = [(1, r"images/some.ico")], > dest_base = r"prog\wx_embed") > > setup( > classifiers = ["Copyright:: your name", > "Development Status :: 5 Stable", > "Intended Audience :: End User", > "License :: Shareware", > "Operating System :: Microsoft :: Windows 2000", > "Operating System :: Microsoft :: Windows XP", > "Operating System :: Microsoft :: Windows 9x", > "Programming Language :: Python, wxPython", > "Topic :: Home Use" > "Natural Language :: German", > "Natural Language :: French", > "Natural Language :: English"], > windows = [wx_emb], > options = options, > zipfile = zipfile, > data_files = [("lib\\matplotlibdata", [os.sep.join([mp.get_data_path(), > 'matplotlibrc'])]), > ("lib\\matplotlibdata\\fonts\\afm", > matplotlib_font_afm), > ("lib\\matplotlibdata\\fonts\\pdfcorefonts", > matplotlib_font_pdfcorefonts), > ("lib\\matplotlibdata\\fonts\\ttf", > matplotlib_font_ttf), > ("lib\\matplotlibdata\\images", matplotlib_images), > ] > ) > > #!/usr/bin/env python > # embedding_in_wx.py > # > > """ > Copyright (C) Jeremy O'Donoghue, 2003 > > License: This work is licensed under the PSF. A copy should be included > with this source code, and is also available at > http://www.python.org/psf/license.html > > This is a sample showing how to embed a matplotlib figure in a wxPanel. > > The example implements the full navigation toolbar, so you can > automatically > inherit standard matplotlib features such as the ability to zoom, pan and > save figures in the supported formats. > > There are a few small complexities worth noting in the example: > > 1) By default, a wxFrame can contain a toolbar (added with SetToolBar()) > but this is at the top of the frame. Matplotlib default is to put the > controls at the bottom of the frame, so you have to manage the toolbar > yourself. I have done this by putting the figure and toolbar into a > sizer, but this means that you need to override GetToolBar for your > wxFrame so that the figure manager can find the toolbar. > > 2) I have implemented a figure manager to look after the plots and axes. > If you don't want a toolbar, it is simpler to add the figure directly > and not worry. However, the figure manager looks after clipping of the > figure contents, so you will need it if you want to navigate > > 3) There is a bug in the way in which my copy of wxPython calculates > toolbar width on Win32, so there is a tricky line to ensure that the > width of the toolbat is the same as the width of the figure. > > 4) Depending on the parameters you pass to the sizer, you can make the > figure resizable or not. > """ > > import matplotlib > matplotlib.use('WX') > from matplotlib.backends.backend_wx import Toolbar, FigureCanvasWx,\ > FigureManager > > from matplotlib.figure import Figure > from matplotlib.axes import Subplot > import matplotlib.numerix as numpy > import wx > > > > class PlotFigure(wx.Frame): > def __init__(self): > wx.Frame.__init__(self, None, -1, "Test embedded wxFigure") > > self.fig = Figure((9,8), 75) > self.canvas = FigureCanvasWx(self, -1, self.fig) > self.toolbar = Toolbar(self.canvas) > self.toolbar.Realize() > > # On Windows, default frame size behaviour is incorrect > # you don't need this under Linux > tw, th = self.toolbar.GetSizeTuple() > fw, fh = self.canvas.GetSizeTuple() > self.toolbar.SetSize(wx.Size(fw, th)) > > # Create a figure manager to manage things > self.figmgr = FigureManager(self.canvas, 1, self) > # Now put all into a sizer > sizer = wx.BoxSizer(wx.VERTICAL) > # This way of adding to sizer allows resizing > sizer.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW) > # Best to allow the toolbar to resize! > sizer.Add(self.toolbar, 0, wx.GROW) > self.SetSizer(sizer) > self.Fit() > > def plot_data(self): > # Use ths line if using a toolbar > a = self.fig.add_subplot(111) > > # Or this one if there is no toolbar > #a = Subplot(self.fig, 111) > > t = numpy.arange(0.0,3.0,0.01) > s = numpy.sin(2*numpy.pi*t) > c = numpy.cos(2*numpy.pi*t) > a.plot(t,s) > a.plot(t,c) > self.toolbar.update() > > def GetToolBar(self): > # You will need to override GetToolBar if you are using an > # unmanaged toolbar in your frame > return self.toolbar > > if __name__ == '__main__': > app = wx.PySimpleApp() > frame = PlotFigure() > frame.plot_data() > frame.Show() > app.MainLoop() > > Hey man... you are great... thanks a lot for your valuable help!!!!!!!!!!!
Hi Viray, Viraj Vajratkar wrote: > ... > well i run "python setup.py py2exe" in the console but it finally > gives : "error: can't copy > 'F:\Python25\Lib\site-packages\matplotlib\mpl-data\fonts' : does'nt > exist or not a regular file" (when actually there is a directory > called mpl-data which has 3 subdirectories ... afm, pdfcorefonts and > ttf). Build and dist folders are made but thr is no .exe in dist. > so i used this setup : The following works for me on WinXP , 2000 and Vista with matplotlib 0.90.1: # matplotlib data import matplotlib as mp matplotlib_font_afm = glob.glob(os.sep.join([mp.get_data_path(), 'fonts/afm/*'])) matplotlib_font_pdfcorefonts = glob.glob(os.sep.join([mp.get_data_path(), 'fonts/pdfcorefonts/*'])) matplotlib_font_ttf = glob.glob(os.sep.join([mp.get_data_path(), 'fonts/ttf/*'])) matplotlib_images = glob.glob(os.sep.join([mp.get_data_path(), 'images/*'])) ... data_files = [ ... ("lib\\matplotlibdata", [os.sep.join([mp.get_data_path(), 'matplotlibrc'])]), ("lib\\matplotlibdata\\fonts\\afm", matplotlib_font_afm), ("lib\\matplotlibdata\\fonts\\pdfcorefonts", matplotlib_font_pdfcorefonts), ("lib\\matplotlibdata\\fonts\\ttf", matplotlib_font_ttf), ("lib\\matplotlibdata\\images", matplotlib_images), ] Hope this helps Werner
Dear All, I have a code that creates plots using pylab module, using pylab.plot(). I want to set the output into binary data. Would you please help me? Thank you in advance. Navid --------------------------------- Pinpoint customers who are looking for what you sell.
i hav a .py script called letsc.py: (python2.5, matplotlib0.90.1, and py2exe for python 2.5 all on windows xp) from Tkinter import * class GUIFramework(Frame): """This is the GUI""" def __init__(self,master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Type Some Text") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): """Create all the widgets that we need""" """Create the Text""" """Create the Entry, set it to be a bit wider""" self.enText1 = Entry(self) self.enText1.grid(row=0, column=1, columnspan=3) self.enText2 = Entry(self) self.enText2.grid(row=1, column=1, columnspan=3) self.enText3 = Entry(self) self.enText3.grid(row=2, column=1, columnspan=3) """Create the Button, set the text and the command that will be called when the button is clicked""" self.btnDisplay = Button(self, text="Display!", command=self.Display ) self.btnDisplay.grid(row=0, column=4) def Display(self): from pylab import * """Called when btnDisplay is clicked, displays the contents of self.enText""" t = arange(0.0, 2.0, 0.01) s = (float(self.enText1.get()))*t*t + (float(self.enText2.get()))*t + (float(self.enText3.get())) plot(t, s, linewidth=1.0) xlabel('x (m)') ylabel('T (K)') title('The sought after Graph!!!') grid(True) show() if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() so clearly i use matplotlib... i now use py2exe for distributin wat i made on other XP comps.. .sp i make a setup.py as per http://www.py2exe.org/index.cgi/MatPlotLib from distutils.core import setup import py2exe import matplotlib setup(windows=['letsc.py'], options={ 'py2exe': { 'packages' : ['matplotlib', 'pytz'], } }, data_files=[matplotlib.get_py2exe_datafiles()] ) well i run "python setup.py py2exe" in the console but it finally gives : "error: can't copy 'F:\Python25\Lib\site-packages\matplotlib\mpl-data\fonts' : does'nt exist or not a regular file" (when actually there is a directory called mpl-data which has 3 subdirectories ... afm, pdfcorefonts and ttf). Build and dist folders are made but thr is no .exe in dist. so i used this setup : from distutils.core import setup import glob import py2exe import matplotlib data = glob.glob(r'F:\Python25\Lib\site-packages\matplotlib\*\*\*\*\*') setup(windows=["letsc.py"], options={ 'py2exe': { 'packages' : ['matplotlib', 'pytz'], } }, data_files=[("matplotlibdata",data)], ) Well now it does giv me my letsc.exe but on clicking the display button in it (on which it shud show a graph using matplot) it gives the following error log : Exception in Tkinter callback Traceback (most recent call last): File "Tkinter.pyc", line 1403, in __call__ File "letsc.py", line 49, in Display File "matplotlib\pylab.pyc", line 2023, in plot File "matplotlib\pylab.pyc", line 937, in ishold File "matplotlib\pylab.pyc", line 883, in gca File "matplotlib\pylab.pyc", line 893, in gcf File "matplotlib\pylab.pyc", line 859, in figure File "matplotlib\backends\backend_tkagg.pyc", line 90, in new_figure_manager File "matplotlib\backends\backend_tkagg.pyc", line 274, in __init__ File "matplotlib\backends\backend_tkagg.pyc", line 545, in __init__ File "matplotlib\backend_bases.pyc", line 1163, in __init__ File "matplotlib\backends\backend_tkagg.pyc", line 590, in _init_toolbar File "matplotlib\backends\backend_tkagg.pyc", line 573, in _Button File "Tkinter.pyc", line 3270, in __init__ File "Tkinter.pyc", line 3226, in __init__ TclError: couldn't open "F:\Python25\dist\matplotlibdata\images\home.ppm": no such file or directory so basically after a lot of efforts its frustrating... so any help appreciated.... thanx
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 >
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.
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
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 >
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.
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
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
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
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() >
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
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
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 >
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.
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
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
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.
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
signal seeker wrote: > Bill, > > The problem is I am writing a bunch of diagonistic tools for users who > do not know anything about unix. > they just want to type a bunch of commands on a shell and see the plots > and they hardly know anything fancy like sending processes to the > background :) > > I guess, I am going to have to use threads or sub processes to spawn new > plots. That's exactly what Bill's ezplot is supposed to do. I am sure that he will appreciate any helping making it easier to just work without the user having to know or do anything. (I know I will.)
Bill, The problem is I am writing a bunch of diagonistic tools for users who do not know anything about unix. they just want to type a bunch of commands on a shell and see the plots and they hardly know anything fancy like sending processes to the background :) I guess, I am going to have to use threads or sub processes to spawn new plots. Thanks, ss On 6/13/07, Bill Baxter <wb...@gm...> wrote: > > On 6/13/07, signal seeker <see...@gm...> wrote: > > > > Bill, > > > > Thanks for your reply. pylab(ion) is not what I meant. Consider this > simply > > script - > > ..... > > # simple.py > > from pylab import * > > plot([1,2,3]) > > show() > > .... > > > > Now, if I do python simple.py on a cmd prompt, this will open up a plot > > window, but the script won't return until the plot window is closed. > > I would like simple.py process to end but the plot window to be still > up. I > > have users who would like to type one command after another and not have > to > > close any of the plot windows created. > > I see. In that case, I think you just want > $ simple.py & > on unix and > c:\> start python simple.py > on Windows. > > In both cases you can put those commands into a script so the user > just types 'run_simple'. > > --bb >
Steve, Thank you, I think you are right in general (the multiply by 60000 is correct though). Since mucking about with my code a bit more it has disappeared. Just strange to see an additive, as opposed to multiplicative, error given the type of calcs that I am doing, hence my doubting the meaning of the label. many thanks -Stuart Steve Schmerler said: >> lines1.extend(pylab.plot(In, inputFlow * 60000, 'g--')) > > Couldn't it be because of "inputFlow * 60000", which may cause the > plotted values to be large (so it is related to what you do > numerically)? The same happens for e.g. plot(array([1,2,3])+1e5), i.e. > if the values' changes are small compared to their magnitude. Without > that, the tick numbers would read 100001.0, 100002.0, 100003.0 in this > example, which may not look very pretty. ----------------------------- Stuart Yarrow