[Matplotlib-users] @image_comparison decorator and unittests
Hi all, is it possible to use the @image_comparison decorator for tests generated within a unittest.TestCase class? With my attempts so far the decorator was indeed instanicated at run time but the test was not called, i.e. the test would allways pass... Running the test with decorator from outside the class works fine. Any idea? Thanks, Fabien -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] @image_comparison decorator and unittests
Thank you all for your replies. It's not an urgent problem: 1. Jens gave us a link to an existing third party lib, althought it's not clear to me how it will work without pytest (i.e. with standard unittest). 2. My workaround is simply to use top level test functions as you suggest, and the rest works just fine. It's already awesome enough to be able to test my plots in such an easy way!!! Thanks a lot, Fabien On 07/30/2015 04:29 PM, Paul Hobson wrote: Fabien, The @image_comparison operator is still somehwat of a black box for me. But I can confirm your observation that it only works on top-level test functions, not within a class. It's on my long, and slowly shifting backlog of things to try to improve. -paul On Thu, Jul 30, 2015 at 6:47 AM, Jens Nielsen jenshniel...@gmail.com mailto:jenshniel...@gmail.com wrote: Thomas Robitailles pytest image comparison plugin might also be of interest https://github.com/astrofrog/pytest-mpl Jens tor. 30. jul. 2015 kl. 14.43 skrev Thomas Caswell tcasw...@gmail.com mailto:tcasw...@gmail.com: Paul Hobson expressed interest in making it easier to use the image comparison tests out side of the mpl test suite Tom On Thu, Jul 30, 2015, 9:28 AM Fabien fabien.mauss...@gmail.com mailto:fabien.mauss...@gmail.com wrote: Hi all, is it possible to use the @image_comparison decorator for tests generated within a unittest.TestCase class? With my attempts so far the decorator was indeed instanicated at run time but the test was not called, i.e. the test would allways pass... Running the test with decorator from outside the class works fine. Any idea? Thanks, Fabien -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net mailto:Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net mailto:Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Misleading BoundaryNorm error
On 07/29/2015 10:34 PM, Paul Hobson wrote: See the following example: import matplotlib as mpl c = mpl.cm.get_cmap() bnorm = mpl.colors.BoundaryNorm([0,1,2], c.N) nnorm = mpl.colors.Normalize(0, 2) # This works: In [8]: c(nnorm(1.1)) Out[8]: (0.64199873497786197, 1.0, 0.32574320050600891, 1.0) # This doesn't: In [9]: c(bnorm(1.1)) (...) TypeError: 'numpy.int16' object does not support item assignment # But this works: In [10]: c(bnorm([1.1])) Out[10]: array([[ 0.5, 0. , 0. , 1. ]]) From the doc I would expect BoundaryNorm and Normalize to work the same way. I find the error sent by BoundaryNorm quite misleading. Should I fill a bug report for this? Fabien, What happens if your force the boundaries to floats? By that I mean: bnorm = mpl.colors.BoundaryNorm([0.0, 1.0, 2.0], c.N) -Paul Thanks Paul, it doesn't change anything. The problem is related to the variable iret which is of shape (): the assignment fails at L1281 in colors.py. Here is the code: def __call__(self, x, clip=None): if clip is None: clip = self.clip x = ma.asarray(x) # --- doesnt guarantee 1D mask = ma.getmaskarray(x) xx = x.filled(self.vmax + 1) if clip: np.clip(xx, self.vmin, self.vmax) iret = np.zeros(x.shape, dtype=np.int16) # --- x.shape = () for i, b in enumerate(self.boundaries): iret[xx = b] = i if self._interp: scalefac = float(self.Ncmap - 1) / (self.N - 2) iret = (iret * scalefac).astype(np.int16) iret[xx self.vmin] = -1 # --- error iret[xx = self.vmax] = self.Ncmap ret = ma.array(iret, mask=mask) if ret.shape == () and not mask: ret = int(ret) return ret It should be easy to fix by changing iret = np.zeros(x.shape, dtype=np.int16) to: iret = np.atleast1d(np.zeros(x.shape, dtype=np.int16)) But this would lead to an output which is never a scalar even if a scalar is given as input. Is that a problem? Cheers, Fabien -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Misleading BoundaryNorm error
On 07/30/2015 10:07 AM, Eric Firing wrote: Forcing the scalar to be a 1-element array would still leave the API inconsistent with what you show for Normalize. One solution is to flag a scalar at the start, and then de-reference at the end. Would you like to submit a PR to take care of this? Hi, my very first PR here: https://github.com/matplotlib/matplotlib/pull/4824 Thanks, Fabien -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Misleading BoundaryNorm error
Folks, still in my exploring phase of Matplotlib's ecosystem I ran into following mismatch between the APIs of BoundaryNorm and Normalize. See the following example: import matplotlib as mpl c = mpl.cm.get_cmap() bnorm = mpl.colors.BoundaryNorm([0,1,2], c.N) nnorm = mpl.colors.Normalize(0, 2) # This works: In [8]: c(nnorm(1.1)) Out[8]: (0.64199873497786197, 1.0, 0.32574320050600891, 1.0) # This doesn't: In [9]: c(bnorm(1.1)) (...) TypeError: 'numpy.int16' object does not support item assignment # But this works: In [10]: c(bnorm([1.1])) Out[10]: array([[ 0.5, 0. , 0. , 1. ]]) From the doc I would expect BoundaryNorm and Normalize to work the same way. I find the error sent by BoundaryNorm quite misleading. Should I fill a bug report for this? Thanks! Fabien -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] BrokenBarHCollection with pandas timeseries
Folks, I'm trying to use BrokenBarHCollection with pandas timeseries object. Here's a minimal example: (python 3.3, pandas 0.15.1, matplotlib 1.4.2) #- import pandas as pd import numpy as np from datetime import datetime as dt import matplotlib.pyplot as plt import matplotlib.collections as collections span_where = collections.BrokenBarHCollection.span_where # init the dataframe time = pd.date_range(pd.datetime(1950,1,1), periods=5, freq='MS') df = pd.DataFrame(np.arange(5), index=time, columns=['data']) df['cond'] = df['data'] == 3 # Make the plot fig = plt.figure() ax = fig.add_subplot(111) df['data'].plot(ax=ax, c='black') c = span_where(df.index, ymin=0, ymax=4, where=df['cond'], facecolor='green', alpha=0.5) #- I get the error: TypeError: float() argument must be a string or a number Basically, span_where() is not happy with my x values which are a panda timeserie. I tried several stuffs (df.index.to_*) but there is something I still don't get in the internal representation of dates in matplolib. Any hint? Thanks a lot! Fabien -- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] BrokenBarHCollection with pandas timeseries
On 02.12.2014 16:34, Benjamin Root wrote: Please provide the full traceback sure, I pasted the traceback below. Here are the pandas infos: In [17]: df.info() class 'pandas.core.frame.DataFrame' DatetimeIndex: 5 entries, 1950-01-01 00:00:00 to 1950-05-01 00:00:00 Freq: MS Data columns (total 2 columns): data5 non-null int64 cond5 non-null bool dtypes: bool(1), int64(1) memory usage: 85.0 bytes In [18]: df.index Out[18]: class 'pandas.tseries.index.DatetimeIndex' [1950-01-01, ..., 1950-05-01] Length: 5, Freq: MS, Timezone: None In [19]: df.index.values Out[19]: array(['1950-01-01T00:00:00.0Z', '1950-02-01T00:00:00.0Z', '1950-03-01T00:00:00.0Z', '1950-04-01T00:00:00.0Z', '1950-05-01T00:00:00.0Z'], dtype='datetime64[ns]') Traceback: In [16]: c = span_where(df.index, ymin=0, ymax=4, where=df['cond'], color='green') --- TypeError Traceback (most recent call last) ipython-input-16-d033044a6db2 in module() 1 c = span_where(df.index, ymin=0, ymax=4, where=df['cond'], color='green') /home/mowglie/.pyvirtualenvs/py3.3/lib/python3.3/site-packages/matplotlib/collections.py in span_where(x, ymin, ymax, where, **kwargs) 871 872 collection = BrokenBarHCollection( -- 873 xranges, [ymin, ymax - ymin], **kwargs) 874 return collection 875 /home/mowglie/.pyvirtualenvs/py3.3/lib/python3.3/site-packages/matplotlib/collections.py in __init__(self, xranges, yrange, **kwargs) 851 (xmin + xwidth, ymin), 852 (xmin, ymin)] for xmin, xwidth in xranges] -- 853 PolyCollection.__init__(self, verts, **kwargs) 854 855 @staticmethod /home/mowglie/.pyvirtualenvs/py3.3/lib/python3.3/site-packages/matplotlib/collections.py in __init__(self, verts, sizes, closed, **kwargs) 799 Collection.__init__(self, **kwargs) 800 self.set_sizes(sizes) -- 801 self.set_verts(verts, closed) 802 803 def set_verts(self, verts, closed=True): /home/mowglie/.pyvirtualenvs/py3.3/lib/python3.3/site-packages/matplotlib/collections.py in set_verts(self, verts, closed) 819 codes[0] = mpath.Path.MOVETO 820 codes[-1] = mpath.Path.CLOSEPOLY -- 821 self._paths.append(mpath.Path(xy, codes)) 822 else: 823 self._paths.append(mpath.Path(xy)) /home/mowglie/.pyvirtualenvs/py3.3/lib/python3.3/site-packages/matplotlib/path.py in __init__(self, vertices, codes, _interpolation_steps, closed, readonly) 135 vertices = vertices.astype(np.float_).filled(np.nan) 136 else: -- 137 vertices = np.asarray(vertices, np.float_) 138 139 if codes is not None: /home/mowglie/.pyvirtualenvs/py3.3/lib/python3.3/site-packages/numpy/core/numeric.py in asarray(a, dtype, order) 460 461 -- 462 return array(a, dtype, copy=False, order=order) 463 464 def asanyarray(a, dtype=None, order=None): TypeError: float() argument must be a string or a number -- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] BrokenBarHCollection with pandas timeseries
OK I just filled a bug report: https://github.com/matplotlib/matplotlib/issues/3872 my first bug report ever! On 02.12.2014 17:15, Fabien wrote: On 02.12.2014 16:59, Benjamin Root wrote: Does the workaround posted here fix things for you? https://github.com/matplotlib/matplotlib/issues/3727#issuecomment-60899590 sorry it doesn't. I updated the test case below (including the workaround, I hope I got it right). The strange thing is that fill_between() works fine, but pan_where() is the problem. Thanks! #--- import pandas as pd import numpy as np from datetime import datetime as dt import matplotlib.pyplot as plt import matplotlib.collections as collections span_where = collections.BrokenBarHCollection.span_where import matplotlib.units as units units.registry[np.datetime64] = pd.tseries.converter.DatetimeConverter() # init the dataframe time = pd.date_range(pd.datetime(1950,1,1), periods=5, freq='MS') df = pd.DataFrame(np.arange(5), index=time, columns=['data']) df['cond'] = df['data'] = 3 # This is working (but its not what I want) x = np.arange(5) fig = plt.figure() ax = fig.add_subplot(111) plt.plot(x, df['data'], 'k') c = span_where(x, ymin=0, ymax=4, where=df['cond'], color='green') ax.add_collection(c) plt.show() #This is not x = df.index.values fig = plt.figure() ax = fig.add_subplot(111) plt.plot(x, df['data'], 'k') c = span_where(x, ymin=0, ymax=4, where=df['cond'], color='green') ax.add_collection(c) plt.show() #This is producing an error x = df.index fig = plt.figure() ax = fig.add_subplot(111) plt.plot(x, df['data'], 'k') c = span_where(x, ymin=0, ymax=4, where=df['cond'], color='green') ax.add_collection(c) plt.show() #--- -- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] BrokenBarHCollection with pandas timeseries
On 02.12.2014 16:59, Benjamin Root wrote: Does the workaround posted here fix things for you? https://github.com/matplotlib/matplotlib/issues/3727#issuecomment-60899590 sorry it doesn't. I updated the test case below (including the workaround, I hope I got it right). The strange thing is that fill_between() works fine, but pan_where() is the problem. Thanks! #--- import pandas as pd import numpy as np from datetime import datetime as dt import matplotlib.pyplot as plt import matplotlib.collections as collections span_where = collections.BrokenBarHCollection.span_where import matplotlib.units as units units.registry[np.datetime64] = pd.tseries.converter.DatetimeConverter() # init the dataframe time = pd.date_range(pd.datetime(1950,1,1), periods=5, freq='MS') df = pd.DataFrame(np.arange(5), index=time, columns=['data']) df['cond'] = df['data'] = 3 # This is working (but its not what I want) x = np.arange(5) fig = plt.figure() ax = fig.add_subplot(111) plt.plot(x, df['data'], 'k') c = span_where(x, ymin=0, ymax=4, where=df['cond'], color='green') ax.add_collection(c) plt.show() #This is not x = df.index.values fig = plt.figure() ax = fig.add_subplot(111) plt.plot(x, df['data'], 'k') c = span_where(x, ymin=0, ymax=4, where=df['cond'], color='green') ax.add_collection(c) plt.show() #This is producing an error x = df.index fig = plt.figure() ax = fig.add_subplot(111) plt.plot(x, df['data'], 'k') c = span_where(x, ymin=0, ymax=4, where=df['cond'], color='green') ax.add_collection(c) plt.show() #--- -- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Matplotlib lag on windows seven
I have installed MPL 1.2.0 but it's still laggy... 2013/1/18 Paul Hobson pmhob...@gmail.com On Thu, Jan 17, 2013 at 8:10 AM, Fabien Lafont lafont.fab...@gmail.comwrote: Thanks! I have:Qt4Agg 2013/1/17 Benjamin Root ben.r...@ou.edu On Thu, Jan 17, 2013 at 8:43 AM, Fabien Lafont lafont.fab...@gmail.comwrote: What is a backend??? The version number? I'm using Matplotlib 1.1.1 from pylab import * get_backend() Ben Root It is probably coincidence, but I noted MPL running way faster when I stopped using QT4Agg and upgraded to 1.2.0. Try upgrading and report back. -paul -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Matplotlib lag on windows seven
Hello everyone, I've just changed my computer from a old core 2 duo on windows Xp to a intel Xeon with 12 Gb Ram. I've installed matplotlib but I plot a graph it's about 10 times slower than windows Xp to pan the axis or move the graph. Even if I'm plotting something very simple like that: from pylab import * x = [0,1,2] plot(x,x) show() Do you have any idea? Thanks, Fabien -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_122712___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Matplotlib lag on windows seven
What is a backend??? The version number? I'm using Matplotlib 1.1.1 2013/1/17 Michael Droettboom md...@stsci.edu Which backends are you using on each platform. A difference there is the most likely culprit. Mike On 01/17/2013 08:16 AM, Fabien Lafont wrote: Hello everyone, I've just changed my computer from a old core 2 duo on windows Xp to a intel Xeon with 12 Gb Ram. I've installed matplotlib but I plot a graph it's about 10 times slower than windows Xp to pan the axis or move the graph. Even if I'm plotting something very simple like that: from pylab import * x = [0,1,2] plot(x,x) show() Do you have any idea? Thanks, Fabien -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at:http://p.sf.net/sfu/learnmore_122712 ___ Matplotlib-users mailing listMatplotlib-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_122712 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_122712___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Matplotlib lag on windows seven
Thanks! I have:Qt4Agg 2013/1/17 Benjamin Root ben.r...@ou.edu On Thu, Jan 17, 2013 at 8:43 AM, Fabien Lafont lafont.fab...@gmail.comwrote: What is a backend??? The version number? I'm using Matplotlib 1.1.1 from pylab import * get_backend() Ben Root -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_122712___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Is it possible to have different color for inner and outer face of a 3D plot?
Actually I want to try to plot something like this picture: http://physics.aps.org/assets/d88621a594e78eea With a color for inside and another for outside. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to change the size of the numbers under the axis
Hi, I think I was tired yesterday. matplotlib.rcParams['xtick.labelsize'] = 20.0 works perfectly also with xlabel(name, size= 30) Thanks all, Fabien 2012/8/30 Mark Lawrence breamore...@yahoo.co.uk: On 30/08/2012 19:00, Fabien Lafont wrote: Actually I just want to do it on that plot not on all my future plot. 2012/8/30 Fabrice Silva si...@lma.cnrs-mrs.fr: Le jeudi 30 août 2012 à 19:48 +0200, Fabien Lafont a écrit : I just create two vectors from a .txt file and I plot them. I think I have the latest version of matplotlib. I have at least the last version of python(x,y) from pylab import* import matplotlib matplotlib.rcParams['xtick.labelsize'] = 20.0 In your matplotlib config file axes.titlesize : 10 # fontsize of the axes title axes.labelsize : 10 # fontsize of the x any y labels (see http://matplotlib.sourceforge.net/users/customizing.html ) -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ I think you're looking for this http://matplotlib.sourceforge.net/users/whats_new.html#tick-params -- Cheers. Mark Lawrence. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to change the textsize inside a legend?
Hello, The question is in the title :) Cheers! Fabien -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to change the textsize inside a legend?
Actually I had some problems to find the solution on the web. Finally I've used: matplotlib.rcParams['legend.fontsize'] = 25.0 and it works well Fabien 2012/8/31 Mark Lawrence breamore...@yahoo.co.uk On 31/08/2012 14:42, Fabien Lafont wrote: Hello, The question is in the title :) Cheers! Fabien I don't wish to appear rude as this list is associated with the Python language, but do you ever try a search engine before you ask a question? -- Cheers. Mark Lawrence. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [matplotlib-users] Embed plot in a website?
Hello everyone, I'm wondering if it's possible to have a matplotlib graph online ? I mean zoom drag and so on on a plot? -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to change the size of the numbers under the axis
Hello, Do you know to change the size of the numbers under the axis? fabien -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to change the size of the numbers under the axis
There is no effect... 2012/8/30 Damon McDougall damon.mcdoug...@gmail.com On Thu, Aug 30, 2012 at 05:50:18PM +0200, Fabien Lafont wrote: Hello, Do you know to change the size of the numbers under the axis? import matplotlib matplotlib.rcParams['axes.labelsize'] = 12.0 Hope this helps. -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to change the size of the numbers under the axis
Hi, But how can I do it for every graph and without creating axis? I've seen this example: import numpy as npimport matplotlib.pyplot as plt # plt.figure creates a matplotlib.figure.Figure instancefig = plt.figure()rect = fig.patch # a rectangle instancerect.set_facecolor('lightgoldenrodyellow') ax1 = fig.add_axes([0.1, 0.3, 0.4, 0.4])rect = ax1.patchrect.set_facecolor('lightslategray') for label in ax1.xaxis.get_ticklabels(): # label is a Text instance label.set_color('red') label.set_rotation(45) label.set_fontsize(16) I don't manage to use only label.set_fontsize(16). It looks so complicated. 2012/8/30 Benjamin Root ben.r...@ou.edu On Thu, Aug 30, 2012 at 11:58 AM, Fabien Lafont lafont.fab...@gmail.comwrote: There is no effect... 2012/8/30 Damon McDougall damon.mcdoug...@gmail.com On Thu, Aug 30, 2012 at 05:50:18PM +0200, Fabien Lafont wrote: Hello, Do you know to change the size of the numbers under the axis? import matplotlib matplotlib.rcParams['axes.labelsize'] = 12.0 Hope this helps. You want to modify xtick.labelsize or ytick.labelsize. By default, they are medium, but you can use a number for it as well. axes.labelsize effects the axes labels, not the labels for the ticks. Cheers! Ben Root -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to change the size of the numbers under the axis
I've tried also but it returns an error: matplotlib.rcParams['xticks.labelsize'] = 12.0 File C:\Python27\lib\site-packages\matplotlib\__init__.py, line 653, in __setitem__ See rcParams.keys() for a list of valid parameters.' % (key,)) KeyError: 'xticks.labelsize is not a valid rc parameter.See rcParams.keys() for a list of valid parameters.' 2012/8/30 Damon McDougall damon.mcdoug...@gmail.com On Thu, Aug 30, 2012 at 12:04:48PM -0400, Benjamin Root wrote: On Thu, Aug 30, 2012 at 11:58 AM, Fabien Lafont lafont.fab...@gmail.com wrote: There is no effect... 2012/8/30 Damon McDougall damon.mcdoug...@gmail.com On Thu, Aug 30, 2012 at 05:50:18PM +0200, Fabien Lafont wrote: Hello, Do you know to change the size of the numbers under the axis? import matplotlib matplotlib.rcParams['axes.labelsize'] = 12.0 Hope this helps. You want to modify xtick.labelsize or ytick.labelsize. By default, they are medium, but you can use a number for it as well. axes.labelsize effects the axes labels, not the labels for the ticks. Thanks for that, Ben. Apologies if I caused confusion. -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to insert an image in a plot?
Hello, I want to insert an image in a plot, how can I do? Fabien -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to change the size of the numbers under the axis
Thanks, I've found the problem. I use xlabel(name of my axis, size= 30) after matplotlib.rcParams['xtick. labelsize'] = 12.0 and it cancel it! Is it possible to have a name on the axe and matplotlib.rcParams['xticks. labelsize'] = 12.0 ?? 2012/8/30 Damon McDougall damon.mcdoug...@gmail.com On Thu, Aug 30, 2012 at 07:06:14PM +0200, Fabien Lafont wrote: I've tried also but it returns an error: matplotlib.rcParams['xticks.labelsize'] = 12.0 File C:\Python27\lib\site-packages\matplotlib\__init__.py, line 653, in __setitem__ See rcParams.keys() for a list of valid parameters.' % (key,)) KeyError: 'xticks.labelsize is not a valid rc parameter.See rcParams.keys() for a list of valid parameters.' It's actually 'xtick.labelsize'. No 's'. -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to change the size of the numbers under the axis
I'm just trying to plot a graph and add a label to each axis of that graph and change the labelsize of the ticks. 2012/8/30 Damon McDougall damon.mcdoug...@gmail.com On Thu, Aug 30, 2012 at 07:28:40PM +0200, Fabien Lafont wrote: Thanks, I've found the problem. I use xlabel(name of my axis, size= 30) after matplotlib.rcParams['xtick. labelsize'] = 12.0 and it cancel it! Is it possible to have a name on the axe and matplotlib.rcParams['xticks. labelsize'] = 12.0 ?? Wait a minute. What exactly are you trying to do? -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to change the size of the numbers under the axis
I just create two vectors from a .txt file and I plot them. I think I have the latest version of matplotlib. I have at least the last version of python(x,y) from pylab import* import matplotlib matplotlib.rcParams['xtick.labelsize'] = 20.0 B5= genfromtxt(2012-05-14_RC3D3D2C1_D2D1_m18T_18T_Vg32V_20K.dat, usecols =(2)) RH5 = genfromtxt(2012-05-14_RC3D3D2C1_D2D1_m18T_18T_Vg32V_20K.dat, usecols =(3)) #plot(B5,RH5,-o,label = 2012-05-14_RC3D3D2C1_D2D1_m18T_18T_Vg32V_20K.dat) xlabel(u$ B (T)$, size= 30) ylabel(u$R_H (\Omega)$, size= 30) grid() legend() show() 2012/8/30 Benjamin Root ben.r...@ou.edu: On Thu, Aug 30, 2012 at 1:38 PM, Fabien Lafont lafont.fab...@gmail.com wrote: I'm just trying to plot a graph and add a label to each axis of that graph and change the labelsize of the ticks. Could you post your code? What you are describing shouldn't happen. Also, which version of matplotlib are you using? Ben Root -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to change the size of the numbers under the axis
Actually I just want to do it on that plot not on all my future plot. 2012/8/30 Fabrice Silva si...@lma.cnrs-mrs.fr: Le jeudi 30 août 2012 à 19:48 +0200, Fabien Lafont a écrit : I just create two vectors from a .txt file and I plot them. I think I have the latest version of matplotlib. I have at least the last version of python(x,y) from pylab import* import matplotlib matplotlib.rcParams['xtick.labelsize'] = 20.0 In your matplotlib config file axes.titlesize : 10 # fontsize of the axes title axes.labelsize : 10 # fontsize of the x any y labels (see http://matplotlib.sourceforge.net/users/customizing.html ) -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [matplotlib-users] How to switch colormaps
Hello everyone, Is it possible to have automaticaly more than 3 colors when Iplot a graph? When I plot it put the first in blue the second in green the third in red and the fourth in blue again. I want to use more colors to differenciate the curves. Is it possible? Fabien -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [matplotlib-users] How to plot digamma function (psi)
Hello everyone, I try to plot the digamma function of (1/2 + 1/x) but I'm not sure that I'm plotting the good one. I've tried: special.polygamma(0, (1/2 + 1/x)) and special.polygamma(1, (1/2 + 1/x)) but I don't have the same result as with mathcad. I've tried to code it like that: def F(x): return mpmath.diff(lambda x: gamma(1/2 + 1/x),1)/gamma(1/2 + 1/x) But It returns zero division error even when x is in ]0,1] Any idea? -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [matplotlib-users] How to plot digamma function (psi)
Thanks! The problem came from the 1/2 ! For convenience I've found the function digamma on numpy *http://docs.scipy.org/doc/scipy/reference/generated/scipy.special.psi.html But it's quite hard to find it! Maybe we can ask to add digamma in the title between parenthesis? Fabien * 2012/7/10 Damon McDougall damon.mcdoug...@gmail.com On Tue, Jul 10, 2012 at 08:57:24AM -0400, Benjamin Root wrote: On Tue, Jul 10, 2012 at 7:05 AM, Damon McDougall damon.mcdoug...@gmail.comwrote: On Tue, Jul 10, 2012 at 12:27:59PM +0200, Fabien Lafont wrote: But It returns zero division error even when x is in ]0,1] I think it blows up at x = 0. What is the type of x in your usecase? Is it an array? If x contains the element 0, you will get a zero division error. You could try plotting the points explicitly: Another problem might be the 1/2 part, which in python2.x would yield 0 unless one does from __future__ import division. Ben Root Wow, I can't believe I didn't spot that. Nice one. I will update my answer according to Ben's astute observation: from scipy import special from pylab import * x = linspace(0.5, 2.0, num=100, endpoint=True) y = special.polygamma(0, 0.5 + 1.0/x) plot(x, y) show() Thanks Ben. -- Damon McDougall http://damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [matplotlib-users] definition to show quikly a plot
Hello everyone, I have a problem. I have to look at many plots. Usely I do it like that: from pylab import* X1 = genfromtxt(Myfile.dat, usecols =(0)) Y1 = genfromtxt(Myfile.dat, usecols =(1)) plot(X1,Y1, label =My curve) show() But the problem is when I have many plots I have to copy paste and change manually all the name of the variables X1, X2, X3...etc. It's not really convenient. I want to create a def with the name of my file as argument which do something like that: from pylab import* def plotgraph(name): X_name = genfromtxt(name, usecols =(0)) Y_name = genfromtxt(name, usecols =(1)) plot(X_name,Y_name, label =name) plotgraph(MyFile) show() But it doesn't work. Do you know why? Do you have a smarter idea? Thanks! Fab -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [matplotlib-users] definition to show quikly a plot
Thx Francesco, it works great! What for the .T at the end of genfromtxt? 2012/5/29 Francesco Montesano franz.berges...@googlemail.com: Dear Fabien 2012/5/29 Fabien Lafont lafont.fab...@gmail.com: Hello everyone, I have a problem. I have to look at many plots. Usely I do it like that: from pylab import* X1 = genfromtxt(Myfile.dat, usecols =(0)) Y1 = genfromtxt(Myfile.dat, usecols =(1)) plot(X1,Y1, label =My curve) show() But the problem is when I have many plots I have to copy paste and change manually all the name of the variables X1, X2, X3...etc. It's not really convenient. I want to create a def with the name of my file as argument which do something like that: from pylab import* def plotgraph(name): X_name = genfromtxt(name, usecols =(0)) Y_name = genfromtxt(name, usecols =(1)) plot(X_name,Y_name, label =name) plotgraph(MyFile) show() Try this: def plotgraph(name): Plot stuff: name: string file name X_name, Y_name = genfromtxt(name, usecols =(0,1)).T plot(X_name,Y_name, label =name) 'name' should contain already a string, so you have to pass it to genfromtxt. I you pass name, the file name is name and not the what is in the variable. Just a note: if you read the file as 'X_name, Y_name = genfromtxt(name, usecols =(0,1)).T' you open, read and close the file only once. Cheers, Francesco But it doesn't work. Do you know why? Do you have a smarter idea? Thanks! Fab -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- personals: monty...@yahoo.it, monte_...@hotmail.com (messenger), franz.berges...@googlemail.com. work: monte...@mpe.mpg.de http://picasaweb.google.it/franz.bergesund -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [matplotlib-users] How to clear a matplotlib graph in PyQt
Hello everyone, I Have a problem. I have a graph inserted in a PyQt interface and I want to clear it (When I click on a button). I initialise the graph like that: class Graph(FigureCanvas): def __init__(self,parent): self.fig = Figure() self.ax = self.fig.add_subplot(111) FigureCanvas.__init__(self, self.fig) self.R1, time,= [], [] self.l_R1, = self.ax.plot([], self.R1,-o, color = 'b', label='R1') self.fig.canvas.draw() FigureCanvas.updateGeometry(self) Later on the program I append values to the arrays: self.R1 and time and I do: self.l_R1.set_data(time, self.R1) self.fig.canvas.draw() FigureCanvas.updateGeometry(self) So the values are correctly added to the Graph. My problem is I want to clear the graph and re-initialize the arrays self.R1 and time to empty arrays. I've tried to create a def activated by a button that do: self.R1, time,= [], [] self.l_R1, = self.ax.plot([], self.R1,-o, color = 'b', label='R1') self.fig.canvas.draw() FigureCanvas.updateGeometry(self) But no effects... Anybody has an idea? Thanks! Fab -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [matplotlib-users] Is it possible to set .pdf as defaut when saving an image?
Is it possible to set the extension .pdf as defaut when I save an image using the matplotlib bar. My coworkers are always saving the image in png and it's really ugly! Thx, Fab -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [matplotlib-users] Is it possible to show a fullscreen plot on windows?
The question is inside the title... -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [matplotlib-users] How connect axes on matplotlib subplots
Hello! How can I zoom exactly on the same region on two different subplots at the same time. This option is enable when I use plotfile but not if I use plot, and subplots? Thx! Fabien -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [matplotlib-users] How connect axes on matplotlib subplots
Thx! 2012/2/2 Angus McMorland amcm...@gmail.com: On 2 February 2012 08:32, Fabien Lafont lafont.fab...@gmail.com wrote: Hello! How can I zoom exactly on the same region on two different subplots at the same time. This option is enable when I use plotfile but not if I use plot, and subplots? Create the first axes object, then when you create subsequent ones, pass the first as the value of the sharex and sharey keywords to the subplot or add_axes command. See this page [1] for a quick example. Angus [1] http://matplotlib.sourceforge.net/users/recipes.html?highlight=sharex%20subplot Thx! Fabien -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- AJC McMorland Post-doctoral research fellow Neurobiology, University of Pittsburgh -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [matplotlib-users] Set the color of a plot in argument's function
I don't manage to put the color of my plot in the argument' list function. Example: def function(color): plot(x,y,'.', color, label = this is my curve) function('r') even if I put function( 'r' ) it doesn't work. Any idea? -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [matplotlib-users] Set the color of a plot in argument's function
Thanks Daryl, it works! 2012/2/2 Daryl Herzmann akrh...@iastate.edu: On Thu, Feb 2, 2012 at 8:52 AM, Fabien Lafont lafont.fab...@gmail.com wrote: I don't manage to put the color of my plot in the argument' list function. Example: def function(color): plot(x,y,'.', color, label = this is my curve) function('r') even if I put function( 'r' ) it doesn't work. Any idea? I would suggest using named arguments for everything other than x and y, so plot(x,y,marker=',', color=color, label='this is my curve') http://matplotlib.sourceforge.net/api/axes_api.html?highlight=plot#matplotlib.axes.Axes.plot daryl -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to keep only the x first terms of an array(numpy)?
Hello, Do somebody knows how to keep only the x first terms of a numpy 1D array? like a = array([8,4,5,7,9]) function(a,2) [8,4] -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?
I want to plot something like: X(time)Ypoints 08 1 2 7 3 4 5 6 7 8 9 -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?
Sorry, It's an awkward manipulation. I finish the mail 2012/1/27 Fabien Lafont lafont.fab...@gmail.com: I want to plot something like: X(time) Ypoints 0 8 1 2 7 36 44 5 6 77 82 9 10 In fact I've recorded some live datas and when I use genfromtxt() the blank parts are translated as 'nan' and I can't for example fit it with polynomials. -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?
Yes in fact it plot it well, but then I have a vector like: [3702.13999, nan, nan, nan, 3703.79, nan, nan, nan, 3704.69001, 3704.84001] and it's impossible to fit it. It return 'nan'. Ive tried: for i in range(0,NbPts): if column1[i] == nan: column1[i].remove(nan) column2[i].remove(nan) to remove these points but it doesn't work 2012/1/27 Benjamin Root ben.r...@ou.edu: On Fri, Jan 27, 2012 at 9:52 AM, Fabien Lafont lafont.fab...@gmail.com wrote: Sorry, It's an awkward manipulation. I finish the mail 2012/1/27 Fabien Lafont lafont.fab...@gmail.com: I want to plot something like: X(time) Ypoints 0 8 1 2 7 3 6 4 4 5 6 7 7 8 2 9 10 In fact I've recorded some live datas and when I use genfromtxt() the blank parts are translated as 'nan' and I can't for example fit it with polynomials. If you plot the data, it should skip data points that are NaNs and you should see a break in the line IIRC. Is that not what you want? Ben Root -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [matplotlib-users] How to plot y vs x with some missing points in y vector?
Thanks a lot, I'll try to remove the points using isnan() 2012/1/27 Fabrice Silva si...@lma.cnrs-mrs.fr: What about masked arrays ? http://docs.scipy.org/doc/numpy/reference/maskedarray.html -- Fabrice Silva -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [matplotlib-users] Twin yaxis and log scale in menubar
Since I use twiny the button on the menu which allow color changing, log scale and so on, doesn't work. Why? What can I do? thx, Fabien -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [Matplotlib] Autoscale soesn't work
I'm using an example from Sandro's Tosi book. I've just modified it to use random data instead cpu_datas. But the autoscale doesn't work even if I turn self.ax.set_autoscale_on(True). Do you have an Idea why? from pylab import * import random import sys from PyQt4 import QtGui import numpy as np from matplotlib.figure import Figure from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar #=== # #=== class CPUMonitor(FigureCanvas): Matplotlib Figure widget def __init__(self,parent): # first image setup self.fig = Figure() self.ax = self.fig.add_subplot(111) # initialization of the canvas FigureCanvas.__init__(self, self.fig) FigureCanvas.updateGeometry(self) # generates first empty plots self.user, self.nice = [], [] self.l_user, = self.ax.plot([], self.user, label='Voltage') self.l_nice, = self.ax.plot([], self.nice, label='Voltage2') self.ax.set_autoscale_on(True) # force a redraw of the Figure #self.fig.canvas.draw() # start the timer, to trigger an event every x milliseconds) self.timer = self.startTimer(1000) self.timerEvent(None) def get_info(self): val1 = random.randint(0,4) return [val1] def get_info2(self) : val2 = random.randint(0,12) return [val2] def timerEvent(self, evt): Custom timerEvent code, called upon timer event receive result1 = self.get_info() result2 = self.get_info2() # append new data to the datasets self.user.append(result1) self.nice.append(result2) # update lines data using the lists with new data self.l_user.set_data(range(len(self.user)), self.user) self.l_nice.set_data(range(len(self.nice)), self.nice) # force a redraw of the Figure self.fig.canvas.draw() FigureCanvas.updateGeometry(self) #=== # #=== class ApplicationWindow(QtGui.QMainWindow): Example main window def __init__(self): # initialization of Qt MainWindow widget QtGui.QMainWindow.__init__(self) # set window title self.setWindowTitle(QHE manip) # instantiate a widget, it will be the main one self.main_widget = QtGui.QWidget(self) # create a vertical box layout widget vbl = QtGui.QVBoxLayout(self.main_widget) # instantiate our Matplotlib canvas widget qmc = CPUMonitor(self.main_widget) # instantiate the navigation toolbar ntb = NavigationToolbar(qmc, self.main_widget) # pack these widget into the vertical box vbl.addWidget(qmc) vbl.addWidget(ntb) # set the focus on the main widget self.main_widget.setFocus() # set the central widget of MainWindow to main_widget self.setCentralWidget(self.main_widget) # create the GUI application qApp = QtGui.QApplication(sys.argv) # instantiate the ApplicationWindow widget aw = ApplicationWindow() # show the widget aw.show() # start the Qt main loop execution, exiting from this script # with the same return code of Qt application sys.exit(qApp.exec_()) -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Autoscale doesn't work
I'm using an example from Sandro's Tosi book. I've just modified it to use random data instead cpu_datas. But the autoscale doesn't work even if I turn self.ax.set_autoscale_on(True). Do you have an Idea why? from pylab import * import random import sys from PyQt4 import QtGui import numpy as np from matplotlib.figure import Figure from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar #=== # #=== class CPUMonitor(FigureCanvas): Matplotlib Figure widget def __init__(self,parent): # first image setup self.fig = Figure() self.ax = self.fig.add_subplot(111) # initialization of the canvas FigureCanvas.__init__(self, self.fig) FigureCanvas.updateGeometry(self) # generates first empty plots self.user, self.nice = [], [] self.l_user, = self.ax.plot([], self.user, label='Voltage') self.l_nice, = self.ax.plot([], self.nice, label='Voltage2') self.ax.set_autoscale_on(True) # force a redraw of the Figure #self.fig.canvas.draw() # start the timer, to trigger an event every x milliseconds) self.timer = self.startTimer(1000) self.timerEvent(None) def get_info(self): val1 = random.randint(0,4) return [val1] def get_info2(self) : val2 = random.randint(0,12) return [val2] def timerEvent(self, evt): Custom timerEvent code, called upon timer event receive result1 = self.get_info() result2 = self.get_info2() # append new data to the datasets self.user.append(result1) self.nice.append(result2) # update lines data using the lists with new data self.l_user.set_data(range(len(self.user)), self.user) self.l_nice.set_data(range(len(self.nice)), self.nice) # force a redraw of the Figure self.fig.canvas.draw() FigureCanvas.updateGeometry(self) #=== # #=== class ApplicationWindow(QtGui.QMainWindow): Example main window def __init__(self): # initialization of Qt MainWindow widget QtGui.QMainWindow.__init__(self) # set window title self.setWindowTitle(QHE manip) # instantiate a widget, it will be the main one self.main_widget = QtGui.QWidget(self) # create a vertical box layout widget vbl = QtGui.QVBoxLayout(self.main_widget) # instantiate our Matplotlib canvas widget qmc = CPUMonitor(self.main_widget) # instantiate the navigation toolbar ntb = NavigationToolbar(qmc, self.main_widget) # pack these widget into the vertical box vbl.addWidget(qmc) vbl.addWidget(ntb) # set the focus on the main widget self.main_widget.setFocus() # set the central widget of MainWindow to main_widget self.setCentralWidget(self.main_widget) # create the GUI application qApp = QtGui.QApplication(sys.argv) # instantiate the ApplicationWindow widget aw = ApplicationWindow() # show the widget aw.show() # start the Qt main loop execution, exiting from this script # with the same return code of Qt application sys.exit(qApp.exec_()) -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [matplotlib] How to plot with plotfile?
I try to plot some data directly from a file but without any sucess so far... from pylab import * plotfile(test.txt,(0,1)) My test.txt is in the same folder and it's just 1 2 3 5 2 6 4 5 8 It returns Traceback (most recent call last): File C:\Documents and Settings\lafont.LNE\Bureau\plotfile.py, line 19, in module plotfile(test.txt,(0,1)) File C:\Python27\lib\site-packages\matplotlib\pyplot.py, line 1908, in plotfile yname, y = getname_val(cols[i]) File C:\Python27\lib\site-packages\matplotlib\pyplot.py, line 1880, in getname_val name = r.dtype.names[int(identifier)] IndexError: tuple index out of range I don't understand, I do the same as the example on the matplotlib website, but it doesn't work -- RSA(R) Conference 2012 Mar 27 - Feb 2 Save $400 by Jan. 27 Register now! http://p.sf.net/sfu/rsa-sfdev2dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [Python] How to show milliseconds with time?
How can I show the milliseconds with the library time because time.time is precise (or at least show) up to 0.01 seconds and it seems it's not possible to print more than seconds... An idea? I use time.strftime(%H:%M:%S, gmtime(time.time())) Fabien -- RSA(R) Conference 2012 Mar 27 - Feb 2 Save $400 by Jan. 27 Register now! http://p.sf.net/sfu/rsa-sfdev2dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [Matplotlib] Best way to use the time
I'm recording live data and I want to record at the same moment the time (to plot MyData Vs Time). Do you know the bast way to do it because it exists a lot of different classes for that? Fabien -- RSA(R) Conference 2012 Mar 27 - Feb 2 Save $400 by Jan. 27 Register now! http://p.sf.net/sfu/rsa-sfdev2dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to plot Chebyshev polynolmials
I'm trying to plot Chebyshev polynolmials using: numpy.polynomial.Chebyshev: import math from numpy import * from numpy import polynomial as pol from pylab import * from scipy import * from scipy import optimize import warnings warnings.simplefilter('ignore', np.RankWarning) test = pol.Chebyshev(3) print test plot (test) show() === The print return: cheb([ 3.]) === and plot : Traceback (most recent call last): File T:\Dropbox\Thèse\Python\fit sonde\test_poly_Tcheb.py, line 32, in module plot (test) File C:\Python27\lib\site-packages\matplotlib\pyplot.py, line 2458, in plot ret = ax.plot(*args, **kwargs) File C:\Python27\lib\site-packages\matplotlib\axes.py, line 3849, in plot self.add_line(line) File C:\Python27\lib\site-packages\matplotlib\axes.py, line 1443, in add_line self._update_line_limits(line) File C:\Python27\lib\site-packages\matplotlib\axes.py, line 1451, in _update_line_limits p = line.get_path() File C:\Python27\lib\site-packages\matplotlib\lines.py, line 644, in get_path self.recache() File C:\Python27\lib\site-packages\matplotlib\lines.py, line 401, in recache y = np.asarray(yconv, np.float_) File C:\Python27\lib\site-packages\numpy\core\numeric.py, line 235, in asarray return array(a, dtype, copy=False, order=order) TypeError: float() argument must be a string or a number -- Write once. Port to many. Get the SDK and tools to simplify cross-platform app development. Create new or port existing apps to sell to consumers worldwide. Explore the Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join http://p.sf.net/sfu/intel-appdev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to plot Chebyshev polynolmials
No I just want to plot the third Shebitchev polynomial. 2012/1/10 Daniel Hyams dhy...@gmail.com: I think that you're misusing Chebyshev (do you really only want to give 3 as a coefficient..which is just the constant function 3), and you have to evaluate it in order to give matplotlib some x and y data to plot. from matplotlib import pyplot as plt import numpy as np x = np.linspace(-1.0,1.0) test = np.polynomial.Chebyshev((1,2,3)) y = test(x) plt.plot(x,y) plt.show() On Tue, Jan 10, 2012 at 9:10 AM, Fabien Lafont lafont.fab...@gmail.com wrote: I'm trying to plot Chebyshev polynolmials using: numpy.polynomial.Chebyshev: import math from numpy import * from numpy import polynomial as pol from pylab import * from scipy import * from scipy import optimize import warnings warnings.simplefilter('ignore', np.RankWarning) test = pol.Chebyshev(3) print test plot (test) show() === The print return: cheb([ 3.]) === and plot : Traceback (most recent call last): File T:\Dropbox\Thèse\Python\fit sonde\test_poly_Tcheb.py, line 32, in module plot (test) File C:\Python27\lib\site-packages\matplotlib\pyplot.py, line 2458, in plot ret = ax.plot(*args, **kwargs) File C:\Python27\lib\site-packages\matplotlib\axes.py, line 3849, in plot self.add_line(line) File C:\Python27\lib\site-packages\matplotlib\axes.py, line 1443, in add_line self._update_line_limits(line) File C:\Python27\lib\site-packages\matplotlib\axes.py, line 1451, in _update_line_limits p = line.get_path() File C:\Python27\lib\site-packages\matplotlib\lines.py, line 644, in get_path self.recache() File C:\Python27\lib\site-packages\matplotlib\lines.py, line 401, in recache y = np.asarray(yconv, np.float_) File C:\Python27\lib\site-packages\numpy\core\numeric.py, line 235, in asarray return array(a, dtype, copy=False, order=order) TypeError: float() argument must be a string or a number -- Write once. Port to many. Get the SDK and tools to simplify cross-platform app development. Create new or port existing apps to sell to consumers worldwide. Explore the Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join http://p.sf.net/sfu/intel-appdev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Daniel Hyams dhy...@gmail.com -- Write once. Port to many. Get the SDK and tools to simplify cross-platform app development. Create new or port existing apps to sell to consumers worldwide. Explore the Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join http://p.sf.net/sfu/intel-appdev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Write once. Port to many. Get the SDK and tools to simplify cross-platform app development. Create new or port existing apps to sell to consumers worldwide. Explore the Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join http://p.sf.net/sfu/intel-appdev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [ploting data] Live data
I prefer to use the multi-thread method beacause it's easier for me and my colaborators to have the entire acquisition process at the same place. Until then I use a simple one but I hope to use a more complex one in few weeks ( put different voltages on different devices then measure many voltages or current). If I use the domino technique (call the next operation by the end of the previous) it can be complex to read and to edit. Thank you very much anyway! How can I write a multi-thread process? I've just tried to add qApp.processEvents() at the end of my while loop but it doesn't change anything... Thanks again, Fabien 2011/12/13 David Hoese dho...@gmail.com: Yeah I didn't think about suggesting that, but I think it might get complicated. I think he would have to start a one shot timer to call a function to set the voltage. Then that function would also start another one shot timer to call another function that would read from the sample. That function then would start a one shot timer to call the first function again. This way he can be sure that things are called in order and that timing is consistent, just in case the GUI gets complicated or something makes the event loop slow down. He could also use multiple threads. Whatever works for Fabien I guess. -Dave On 12/13/11 1:00 PM, matplotlib-users-requ...@lists.sourceforge.net wrote: From: Drain, Theodore R (343P)theodore.r.dr...@jpl.nasa.gov Subject: Re: [Matplotlib-users] [ploting data] Live data Perhaps I'm missing something, but why not use QTimer? You can't really every call sleep in a single threaded gui (for reasons you've encountered). If you need to poll something, create a QTimer for 2 seconds and have it call a measurement function to update the data. You shouldn't need any processEvents calls or sleep. -- Cloud Computing - Latest Buzzword or a Glimpse of the Future? This paper surveys cloud computing today: What are the benefits? Why are businesses embracing it? What are its payoffs and pitfalls? http://www.accelacomm.com/jaw/sdnl/114/51425149/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Fit with Chebyshev Polynomials
I have a basic problem (I think) I try to fit some data with this function http://docs.scipy.org/doc/numpy/reference/generated/numpy.polynomial.Chebyshev.fit.html But it return an error: fit = chebyshev.fit(T,R,3) NameError: name 'chebyshev' is not defined I don't understand I've imported Numpy and polynomials... An Idea? import math from numpy import * from numpy import polynomial from pylab import * from scipy import * from scipy import optimize import warnings warnings.simplefilter('ignore', np.RankWarning) R = [ 9011.5 , 7822.7 , 6253.9 , 4877.56 , 3892.08 , 3221.41 , 2647.05, 2260.94 , 1959.72 , 1712.06 , 1522.28 , 1367.87 , 1242.953 , 1185.092, 1104.452 , 1031.862 , 919.8644 , 832.9942 , 767.8944 , 715.1569, 671.6301 , 635.1634 , 604.284 , 577.5536] T = range(0,len(R)) plot (T,R,.) show() fit = chebyshev.fit(T,R,3) print fit -- Cloud Computing - Latest Buzzword or a Glimpse of the Future? This paper surveys cloud computing today: What are the benefits? Why are businesses embracing it? What are its payoffs and pitfalls? http://www.accelacomm.com/jaw/sdnl/114/51425149/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Fit with Chebyshev Polynomials
Thx Seb! 2011/12/14 Benjamin Root ben.r...@ou.edu: On Wednesday, December 14, 2011, Fabien Lafont lafont.fab...@gmail.com wrote: I have a basic problem (I think) I try to fit some data with this function http://docs.scipy.org/doc/numpy/reference/generated/numpy.polynomial.Chebyshev.fit.html But it return an error: fit = chebyshev.fit(T,R,3) NameError: name 'chebyshev' is not defined I don't understand I've imported Numpy and polynomials... An Idea? import math from numpy import * from numpy import polynomial from pylab import * from scipy import * from scipy import optimize import warnings warnings.simplefilter('ignore', np.RankWarning) R = [ 9011.5 , 7822.7 , 6253.9 , 4877.56 , 3892.08 , 3221.41 , 2647.05, 2260.94 , 1959.72 , 1712.06 , 1522.28 , 1367.87 , 1242.953 , 1185.092, 1104.452 , 1031.862 , 919.8644 , 832.9942 , 767.8944 , 715.1569, 671.6301 , 635.1634 , 604.284 , 577.5536] T = range(0,len(R)) plot (T,R,.) show() fit = chebyshev.fit(T,R,3) print fit The function would be in the polynomial namespace. So polynomial.chebyshev() would work. To reduce typing, you can import a module as some other name. from numpy import polynomial as poly .. fit = poly.chebyshev.fit(T,R,3) Importing modules is very flexible and I suggest reading up on it. Ben Root -- Cloud Computing - Latest Buzzword or a Glimpse of the Future? This paper surveys cloud computing today: What are the benefits? Why are businesses embracing it? What are its payoffs and pitfalls? http://www.accelacomm.com/jaw/sdnl/114/51425149/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [ploting data] Live data
Thanks David, I start to read the Mark summerfield' book about PyQt programming. In fact I realized I don't need multi-threading because I can remove the Timer and just need to call the graphical application from the while loop. How can I call the ApplicationWindow class from my while loop? I'll try to read a bit more about PyQt to understand how it works :) thanks again! Fabien 2011/12/14 David Hoese dho...@gmail.com: I'm not sure how experienced you are with multithreaded programs, but here is some sample code (I mentioned it can get complicated). I suggest you research Qt4 QThreads and also Qt4 Signals and slots to better understand the code below. It is a working sample so you should be able to run it in a terminal and notice that the GUI is responsive and that you have messages being printed out on the terminal. The code I provided below is more complicated than you may need for a proof-of-concept kind of program, but if you will be communicating with physical devices I suggest something like this. I am by no means and expert, but I have been doing something similar to what you are doing. I also suggest maybe separating the device communication into another module/class, especially if others are going to (re)use your code. Good Luck, Dave P.S. There are a lot of Qt4/PyQt4 threading examples online, but not all of them correct. What I posted below is what I have found to be considered correct by most people. # ### Sample Code ### # import time from PyQt4 import QtGui,QtCore class MyWindow(QtGui.QWidget): def __init__(self): QtGui.QWidget.__init__(self) # Sample GUI elements to test responsiveness the_choices = [item]*20 self.choices = QtGui.QComboBox() self.choices.addItems(the_choices) self.layout = QtGui.QVBoxLayout(self) self.layout.addWidget(self.choices) self.setLayout(self.layout) def handle_new_data(self): # This is where you could redraw any matplotlib plots # Maybe send data through the signal/slot connection print Updating data class MyInstrument(QtCore.QObject): signal_new_data = QtCore.pyqtSignal(name=signal_new_data) signal_closing = QtCore.pyqtSignal(name=signal_closing) def run(self): self._timer = QtCore.QTimer() self._timer.timeout.connect(self._run) self._timer.start(0) def _run(self): time.sleep(1) print Running the instrument function time.sleep(1) self.signal_new_data.emit() def close(self): print Closing instrument thread self._timer.stop() # Redundant timer stop self._timer.timeout.disconnect() self.signal_closing.emit() if __name__ == __main__: app = QtGui.QApplication([ ]) w = MyWindow() w.show() instrument = MyInstrument() instrument_thread = QtCore.QThread() instrument.moveToThread(instrument_thread) instrument_thread.started.connect(instrument.run) instrument.signal_new_data.connect(w.handle_new_data) # Make the close function run in the main thread so you can interrupt the sleeps app.lastWindowClosed.connect(instrument.close, QtCore.Qt.DirectConnection) # You could also call quit manually after exec_() returns instrument.signal_closing.connect(instrument_thread.quit) instrument_thread.start() app.exec_() #instrument_thread.quit() print Waiting for instrument thread... instrument_thread.wait() print SUCCESS ## ### End of Sample Code ### ## On 12/14/11 3:51 AM, Fabien Lafont wrote: I prefer to use the multi-thread method beacause it's easier for me and my colaborators to have the entire acquisition process at the same place. Until then I use a simple one but I hope to use a more complex one in few weeks ( put different voltages on different devices then measure many voltages or current). If I use the domino technique (call the next operation by the end of the previous) it can be complex to read and to edit. Thank you very much anyway! How can I write a multi-thread process? I've just tried to add qApp.processEvents() at the end of my while loop but it doesn't change anything... Thanks again, Fabien 2011/12/13 David Hoesedho...@gmail.com: Yeah I didn't think about suggesting that, but I think it might get complicated. I think he would have to start a one shot timer to call a function to set the voltage. Then that function would also start another one shot timer to call another function that would read from the sample. That function then would start a one shot timer to call the first function again. This way he can be sure that things are called in order and that timing is consistent, just in case the GUI gets complicated or something makes the event loop slow down. He could also use multiple threads. Whatever works for Fabien I guess
Re: [Matplotlib-users] [ploting data] Live data
Hey David, I'm doing this program to control an experiment, so I want to put the voltage on the sample, then wait two seconds to be sure there is no current fluctuations then measure the curent with multimeters and finally plot the datas. That's why I need the sleep... In fact I wanted to use in parallel the timer to refresh the graph and a while loop to extract the datas. If I use startTimer(0) it works but the GUI is almost unresponsive. I'm trying to use qApp.processEvents() but up to now I don't manage to see the window appears... Thanks again for your help Fabien 2011/12/12 David Hoese dho...@gmail.com: Hey Fabien, So you made your principal function run on a timer every 2 seconds? And by lag do you mean that the GUI is unresponsive? I'm still not seeing when the loop stops, but what you can do is set the timer at a 0 interval so it will call the principal function as fast as it can (but with no loop). The problem with this is that you have those 2 sleep calls in the function. I'm not sure why you have the sleeps, but if you need them you have two choices: 1. Make you GUI multi-threaded and you could emit a Qt signal from the data thread when the GUI thread needs to update the GUI. Yes this could get complicated, but if the sleeps are required then its probably the best way. 2. (From what I've been told, the Qt experts don't approve this) You can use app.processEvents() in your loop (after each sleep maybe) and this will pause your function and tell the main event loop to process any queued events (like GUI actions/events) which will make your GUI more responsive. If that doesn't make sense let me know. -Dave On 12/12/11 9:16 AM, Fabien Lafont wrote: Hi David! Sorry about the delay I was abroad and without any way to connect to the internet. Thank you very much. I've tried to put the principal inside the timerEvent. It work but it lags. In fact I've set the interval of the Timer to 2 seconds because the principal loop takes roughly 2seconds but it's not very accurate... Is there a way to do the principal loop, show it on the screen, then redo the loop? Thanks again! Fabien 2011/12/5 David Hoesedho...@gmail.com: If I'm understanding your question correctly and reading your code correctly, you're asking why the timer method of doing things works, but the principal() while loop method does not. I had a couple solutions that involved the main event loop, but I just noticed 2 main things that are probably wrong with your code: 1. You are calling 'principal' from inside __init__ so you never actually return from __init__ which means that you never call window.show() and therefore never call qApp.exec_(). If you really want to use the 'principal' method you would have to connect it to a one shot timer anyway to have it run after you have started the application ('qApp.exec_()'). I think the recommended way would be to use the timer the way you did in your latest email. 2. At least in the way my email client reads your original code, your calls to the matplotlib drawing functions aren't inside the while loop and the while loop never ends...although this doesn't matter if you don't fix #1 above. Hope that made sense. -Dave On 12/5/11 1:44 PM, matplotlib-users-requ...@lists.sourceforge.net wrote: Message: 3 Date: Mon, 5 Dec 2011 15:46:02 +0100 From: Fabien Lafontlafont.fab...@gmail.com Subject: Re: [Matplotlib-users] [ploting data] Live data Cc:matplotlib-users@lists.sourceforge.net Message-ID: CAC9H_cjrgQBE6e6+jzZHyfYHonTeAg0XwU7c_2G-hu=s+z7...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Thx all for your remarks, I can't understand why this code works (when I use the timer method): -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [ploting data] Live data
Hi David! Sorry about the delay I was abroad and without any way to connect to the internet. Thank you very much. I've tried to put the principal inside the timerEvent. It work but it lags. In fact I've set the interval of the Timer to 2 seconds because the principal loop takes roughly 2seconds but it's not very accurate... Is there a way to do the principal loop, show it on the screen, then redo the loop? Thanks again! Fabien 2011/12/5 David Hoese dho...@gmail.com: If I'm understanding your question correctly and reading your code correctly, you're asking why the timer method of doing things works, but the principal() while loop method does not. I had a couple solutions that involved the main event loop, but I just noticed 2 main things that are probably wrong with your code: 1. You are calling 'principal' from inside __init__ so you never actually return from __init__ which means that you never call window.show() and therefore never call qApp.exec_(). If you really want to use the 'principal' method you would have to connect it to a one shot timer anyway to have it run after you have started the application ('qApp.exec_()'). I think the recommended way would be to use the timer the way you did in your latest email. 2. At least in the way my email client reads your original code, your calls to the matplotlib drawing functions aren't inside the while loop and the while loop never ends...although this doesn't matter if you don't fix #1 above. Hope that made sense. -Dave On 12/5/11 1:44 PM, matplotlib-users-requ...@lists.sourceforge.net wrote: Message: 3 Date: Mon, 5 Dec 2011 15:46:02 +0100 From: Fabien Lafontlafont.fab...@gmail.com Subject: Re: [Matplotlib-users] [ploting data] Live data Cc:matplotlib-users@lists.sourceforge.net Message-ID: CAC9H_cjrgQBE6e6+jzZHyfYHonTeAg0XwU7c_2G-hu=s+z7...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Thx all for your remarks, I can't understand why this code works (when I use the timer method): -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Learn Windows Azure Live! Tuesday, Dec 13, 2011 Microsoft is holding a special Learn Windows Azure training event for developers. It will provide a great way to learn Windows Azure and what it provides. You can attend the event by watching it streamed LIVE online. Learn more at http://p.sf.net/sfu/ms-windowsazure ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [ploting data] Live data
Thx all for your remarks, I can't understand why this code works (when I use the timer method): # -*- coding: utf-8 -*- Created on Fri Dec 02 17:10:22 2011 @author: lafont #!/usr/bin/env python from visa import * from pylab import * import sys from PyQt4 import QtGui import numpy as np from matplotlib.figure import Figure from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar #=== # #=== class CPUMonitor(FigureCanvas): Matplotlib Figure widget def __init__(self,parent): # first image setup self.fig = Figure() self.ax = self.fig.add_subplot(111) # initialization of the canvas FigureCanvas.__init__(self, self.fig) # set specific limits for X and Y axes #self.ax.set_xlim(0, 40) #self.ax.set_ylim(0, 1.5) # FigureCanvas.updateGeometry(self) # generates first empty plots self.user, self.nice = [], [] self.l_user, = self.ax.plot([], self.user, label='Voltage') self.l_nice, = self.ax.plot([], self.nice, label='Voltage2') # add legend to plot self.ax.legend() # force a redraw of the Figure self.fig.canvas.draw() # start the timer, to trigger an event every x milliseconds) self.timer = self.startTimer(1000) self.timerEvent(None) def get_info(self): return [0.8] def get_info2(self) : return [0.9] def set_voltage(self) : print ok # def timerEvent(self, evt): Custom timerEvent code, called upon timer event receive result1 = self.get_info() result2 = self.get_info2() # append new data to the datasets self.user.append(result1) self.nice.append(result2) # update lines data using the lists with new data self.l_user.set_data(range(len(self.user)), self.user) self.l_nice.set_data(range(len(self.nice)), self.nice) # force a redraw of the Figure self.fig.canvas.draw() FigureCanvas.updateGeometry(self) #=== # #=== class ApplicationWindow(QtGui.QMainWindow): Example main window def __init__(self): # initialization of Qt MainWindow widget QtGui.QMainWindow.__init__(self) # set window title self.setWindowTitle(QHE manip) # instantiate a widget, it will be the main one self.main_widget = QtGui.QWidget(self) # create a vertical box layout widget vbl = QtGui.QVBoxLayout(self.main_widget) # instantiate our Matplotlib canvas widget qmc = CPUMonitor(self.main_widget) # instantiate the navigation toolbar ntb = NavigationToolbar(qmc, self.main_widget) # pack these widget into the vertical box vbl.addWidget(qmc) vbl.addWidget(ntb) # set the focus on the main widget self.main_widget.setFocus() # set the central widget of MainWindow to main_widget self.setCentralWidget(self.main_widget) # create the GUI application qApp = QtGui.QApplication(sys.argv) # instantiate the ApplicationWindow widget aw = ApplicationWindow() # show the widget aw.show() # start the Qt main loop execution, exiting from this script # with the same return code of Qt application sys.exit(qApp.exec_()) And this code doesn't show anything... Somebody understand why? Thanks, Fabien 2011/12/4 David Hoese dho...@gmail.com I think you forget to set the layout on your central widget. self.main_widget.setLayout(vbl) # in your case -Dave On 12/4/2011 9:57 AM, matplotlib-users-requ...@lists.sourceforge.net wrote: 2011/12/2 Daniel Hyamsdhy...@gmail.com: I don't have PyQt installed, so I couldn't test the code, but don't you want to be using extend and not append, if you are returning a list from your two get_info() functions? On Fri, Dec 2, 2011 at 8:13 AM, Fabien Lafontlafont.fab...@gmail.com wrote: Hello everyone, I'm trying to plot live data extracting from remote devices (here it's simulated by get_info1 and 2 the result is always 0.8 or 0.9 I can't understand why it doesnt plot the graph at the end of the while loop. Does somebody has an idea? -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common
[Matplotlib-users] [ploting data] Live data
Hello everyone, I'm trying to plot live data extracting from remote devices (here it's simulated by get_info1 and 2 the result is always 0.8 or 0.9 I can't understand why it doesnt plot the graph at the end of the while loop. Does somebody has an idea? #!/usr/bin/env python from visa import * from pylab import * import sys from PyQt4 import QtGui import numpy as np from matplotlib.figure import Figure from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar #=== # #=== class CPUMonitor(FigureCanvas): Matplotlib Figure widget def __init__(self,parent): # first image setup self.fig = Figure() self.ax = self.fig.add_subplot(111) # initialization of the canvas FigureCanvas.__init__(self, self.fig) # set specific limits for X and Y axes self.ax.set_xlim(0, 2) self.ax.set_ylim(0, 1.5) # generates first empty plots self.user, self.nice = [], [] self.l_user, = self.ax.plot([], self.user, label='Voltage') self.l_nice, = self.ax.plot([], self.nice, label='Voltage2') self.ax.legend() # force a redraw of the Figure self.fig.canvas.draw() self.principal() def principal(self) : stop = 0 while stop==0 : time.sleep(1) self.set_voltage() time.sleep(1) result1 = self.get_info() result2 = self.get_info2() # append new data to the datasets self.user.append(result1) self.nice.append(result2) self.l_user.set_data(range(len(self.user)), self.user) self.l_nice.set_data(range(len(self.nice)), self.nice) # force a redraw of the Figure self.fig.canvas.draw() FigureCanvas.updateGeometry(self) def get_info(self): return [0.8] def get_info2(self) : return [0.9] def set_voltage(self) : print ok #=== # #=== class ApplicationWindow(QtGui.QMainWindow): Example main window def __init__(self): # initialization of Qt MainWindow widget QtGui.QMainWindow.__init__(self) # set window title self.setWindowTitle(QHE manip) # instantiate a widget, it will be the main one self.main_widget = QtGui.QWidget(self) # create a vertical box layout widget vbl = QtGui.QVBoxLayout(self.main_widget) # instantiate our Matplotlib canvas widget qmc = CPUMonitor(self.main_widget) # instantiate the navigation toolbar ntb = NavigationToolbar(qmc, self.main_widget) # pack these widget into the vertical box vbl.addWidget(qmc) vbl.addWidget(ntb) # set the focus on the main widget self.main_widget.setFocus() # set the central widget of MainWindow to main_widget self.setCentralWidget(self.main_widget) # create the GUI application qApp = QtGui.QApplication(sys.argv) # instantiate the ApplicationWindow widget aw = ApplicationWindow() # show the widget aw.show() # start the Qt main loop execution, exiting from this script # with the same return code of Qt application sys.exit(qApp.exec_()) -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [ploting data] Live data
Thx Daniel I didn't know extend and it's more suitable for my program. It doesn't change the problem of plotting, but thx again! 2011/12/2 Daniel Hyams dhy...@gmail.com: I don't have PyQt installed, so I couldn't test the code, but don't you want to be using extend and not append, if you are returning a list from your two get_info() functions? On Fri, Dec 2, 2011 at 8:13 AM, Fabien Lafont lafont.fab...@gmail.com wrote: Hello everyone, I'm trying to plot live data extracting from remote devices (here it's simulated by get_info1 and 2 the result is always 0.8 or 0.9 I can't understand why it doesnt plot the graph at the end of the while loop. Does somebody has an idea? #!/usr/bin/env python from visa import * from pylab import * import sys from PyQt4 import QtGui import numpy as np from matplotlib.figure import Figure from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar #=== # #=== class CPUMonitor(FigureCanvas): Matplotlib Figure widget def __init__(self,parent): # first image setup self.fig = Figure() self.ax = self.fig.add_subplot(111) # initialization of the canvas FigureCanvas.__init__(self, self.fig) # set specific limits for X and Y axes self.ax.set_xlim(0, 2) self.ax.set_ylim(0, 1.5) # generates first empty plots self.user, self.nice = [], [] self.l_user, = self.ax.plot([], self.user, label='Voltage') self.l_nice, = self.ax.plot([], self.nice, label='Voltage2') self.ax.legend() # force a redraw of the Figure self.fig.canvas.draw() self.principal() def principal(self) : stop = 0 while stop==0 : time.sleep(1) self.set_voltage() time.sleep(1) result1 = self.get_info() result2 = self.get_info2() # append new data to the datasets self.user.append(result1) self.nice.append(result2) self.l_user.set_data(range(len(self.user)), self.user) self.l_nice.set_data(range(len(self.nice)), self.nice) # force a redraw of the Figure self.fig.canvas.draw() FigureCanvas.updateGeometry(self) def get_info(self): return [0.8] def get_info2(self) : return [0.9] def set_voltage(self) : print ok #=== # #=== class ApplicationWindow(QtGui.QMainWindow): Example main window def __init__(self): # initialization of Qt MainWindow widget QtGui.QMainWindow.__init__(self) # set window title self.setWindowTitle(QHE manip) # instantiate a widget, it will be the main one self.main_widget = QtGui.QWidget(self) # create a vertical box layout widget vbl = QtGui.QVBoxLayout(self.main_widget) # instantiate our Matplotlib canvas widget qmc = CPUMonitor(self.main_widget) # instantiate the navigation toolbar ntb = NavigationToolbar(qmc, self.main_widget) # pack these widget into the vertical box vbl.addWidget(qmc) vbl.addWidget(ntb) # set the focus on the main widget self.main_widget.setFocus() # set the central widget of MainWindow to main_widget self.setCentralWidget(self.main_widget) # create the GUI application qApp = QtGui.QApplication(sys.argv) # instantiate the ApplicationWindow widget aw = ApplicationWindow() # show the widget aw.show() # start the Qt main loop execution, exiting from this script # with the same return code of Qt application sys.exit(qApp.exec_()) -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Daniel Hyams dhy...@gmail.com -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense
[Matplotlib-users] [timer] How it works?
Hello everyone, I don't understand how works TimerBase. From matplotlib import backend_bases def write(x): print x backend_bases.TimerBase._timer_start backend_bases.TimerBase(1000,write(2)) It returns only 2 one time. Why it doesn't return 2 every second? Thx in advance, Fabien -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Matplotlib graph autoscale
Hello everyone, I've adapted a python code to plot real time data but I don't manage to have an auto-scale on my graph. I don't understand because I use set_autoscale_on(True) Do you have an idea? Here is my simplified code: #!/usr/bin/env python #from visa import * from pylab import * # for command-line arguments import sys # Python Qt4 bindings for GUI objects from PyQt4 import QtGui # Numpy functions for image creation import numpy as np # Matplotlib Figure object from matplotlib.figure import Figure # import the Qt4Agg FigureCanvas object, that binds Figure to # Qt4Agg backend. It also inherits from QWidget from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas # import the NavigationToolbar Qt4Agg widget from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar ### ### class CPUMonitor(FigureCanvas): Matplotlib Figure widget to display CPU utilization def __init__(self,parent): # first image setup self.fig = Figure() self.ax = self.fig.add_subplot(111) #self.fig.apply__adjustable() # # initialization of the canvas FigureCanvas.__init__(self, self.fig) # set specific limits for X and Y axes #self.ax.set_xlim(0, 2) #self.ax.set_ylim(0, 1.5) # and disable figure-wide autoscale self.ax.set_autoscale_on(True) #self.ax.set_adjustable('datalim') # generates first empty plots self.user, self.nice = [], [] self.l_user, = self.ax.plot([], self.user, label='Voltage') self.l_nice, = self.ax.plot([], self.nice, label='Voltage2') # add legend to plot self.ax.legend() # force a redraw of the Figure #self.fig.canvas.draw() # initialize the iteration counter #self.cnt = 0 # call the update method (to speed-up visualization) self.timerEvent(None) # start the timer, to trigger an event every x milliseconds) self.timer = self.startTimer(100) def get_info(self): #my_instrument1 = instrument(GPIB0::24, term_chars = CR) #my_instrument1.write(DCV ) #my_instrument1.write(TRIG AUTO) #mesure1 = my_instrument1.read_values() fichier = open(fichier.dat, a) fichier.write(str(1)+\t) fichier.close() fichier = open(fichier.dat, a) fichier.write(str(1)+\t) fichier.close() return [0.8] def get_info2(self): #my_instrument2 = instrument(GPIB0::??, term_chars = CR) #my_instrument2.write(DCV ) #my_instrument2.write(TRIG AUTO) #mesure2 = my_instrument2.read_values() # fichier = open(fichier.dat, a) fichier.write(str(2)+\n) fichier.close() return [0.9] def timerEvent(self, evt): Custom timerEvent code, called upon timer event receive # get the value from the device result1 = self.get_info() result2 = self.get_info2() # append new data to the datasets self.user.append(result1) self.nice.append(result2) # update lines data using the lists with new data self.l_user.set_data(range(len(self.user)), self.user) self.l_nice.set_data(range(len(self.nice)), self.nice) # force a redraw of the Figure self.fig.canvas.draw() FigureCanvas.updateGeometry(self) class ApplicationWindow(QtGui.QMainWindow): Example main window def __init__(self): # initialization of Qt MainWindow widget QtGui.QMainWindow.__init__(self) # set window title self.setWindowTitle(QHE manip) # instantiate a widget, it will be the main one self.main_widget = QtGui.QWidget(self) # create a vertical box layout widget vbl = QtGui.QVBoxLayout(self.main_widget) # instantiate our Matplotlib canvas widget qmc = CPUMonitor(self.main_widget) # instantiate the navigation toolbar ntb = NavigationToolbar(qmc, self.main_widget) # pack these widget into the vertical box vbl.addWidget(qmc) vbl.addWidget(ntb) # set the focus on the main widget self.main_widget.setFocus() # set the central widget of MainWindow to main_widget self.setCentralWidget(self.main_widget) # create the GUI application qApp = QtGui.QApplication(sys.argv) # instantiate the ApplicationWindow widget aw = ApplicationWindow() # show the widget aw.show() # start the Qt main loop execution, exiting from this script # with the same return code of Qt application sys.exit(qApp.exec_()) -- All the data