[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
Re: [Matplotlib-users] [timer] How it works?
On Tue, Nov 29, 2011 at 4:16 AM, Fabien Lafont lafont.fab...@gmail.com wrote: 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)) TimerBase is a do-nothing skeleton class that provides the common infrastructure for other backends to implement a timer that works with them (just like the rest of backend_bases). For example, the gtk backend uses this as a starting point for its own timer class. You really shouldn't be instantiating TimerBase yourself as it won't do anything. It returns only 2 one time. Why it doesn't return 2 every second? The only reason you actually see anything at all is because you call write yourself when you do: write(2) The timer never actually does anything. The proper call is to separate the function and its arguments, since as the docs say, it takes a list of (func, args) tuples that will be called upon timer events: TimerBase(1000, [(write, 2)]) However, the proper way to create a timer, which will intergrate properly with the figure event loop, is shown in the example: http://matplotlib.sourceforge.net/examples/event_handling/timers.html In your case: timer = fig.canvas.new_timer(interval=1000) timer.add_callback(write, 2) timer.start() Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- 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] stretch x-axis
Hello all, I am struggling to improve the layout of these subplots. You can see that the x tick labels on the left subplot are crunched. I simply want to stretch the x axis a bit in order to spread out the x ticks. Do you have any suggestions? Thanks! Neil - Here is my code: P.figure() P.subplots_adjust(wspace=0.4) P.subplot(121) P.hist([el_mean_diff,ln_mean_diff],bins=[-.7,-.6,-.5,-.4,-.3,-.2,-.1,0,.1,.2,.3,.4,.5,.6,.7],color=['red','blue'],align='mid') P.title('a) mean') P.xlabel('Average difference at each grid point (m/s) ') P.ylabel('Number of grid points') P.tick_params(axis='both',direction='out',top='off',right='off',length=2,labelsize='10') P.grid(True) P.subplot(122) P.hist([el_stdv_diff,ln_stdv_diff],bins=[-.5,-.4,-.3,-.2,-.1,0,.1,.2,.3,.4,.5],color=['red','blue'],align='mid') P.title('b) standard deviation') P.xlabel('Average difference at each grid point (m/s) ') P.ylabel('Number of grid points') P.tick_params(axis='both',direction='out',top='off',right='off',length=2,labelsize='10') P.grid(True) P.show() inline: histogram.eps-- 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] plot_date with multiple subplots
I have a short script to plot 20 years of river flow data. I can use the plot_date command to create a plot, using this snippet: f = figure() ax1 = f.add_subplot(111) ax1.plot_date(dates0,y1,'g', label='observed', xdate=True,visible=True) ax1.plot_date(dates1,y2,'r', label='simulated', xdate=True,visible=True) years= YearLocator(1, month=6, day=30) # every year months = MonthLocator(1) # every month ax1.set_xlim(date2num(datetime.date(1990,1,1)),date2num(datetime.date(1999,12,31))) ax1.xaxis.set_major_locator(years) ax1.xaxis.set_minor_locator(months) labels = ax1.get_xticklabels() setp(labels, fontsize=8,visible=True) The problem is with the x-axis (time axis) labels when I add a second subplot, to add the next time segment. I change the above to ax1 = f.add_subplot(211), and then: ax2 = f.add_subplot(212) ax2.plot_date(dates0,y1,'g') #plots the time series ax2.plot_date(dates1,y2,'r') #need to call twice, unlike plot, plot_date takes one set ax2.set_xlim(date2num(datetime.date(2000,1,1)),date2num(datetime.date(2009,12,31))) ax2.xaxis.set_major_locator(years) ax2.xaxis.set_minor_locator(months) setp(labels, fontsize=8,visible=True) The x-axis labels only appear for the last subplot. I'm guessing that plot_date assumes that more than one subplot must share a time axis. There must be a simple way to stop plot_date from doing this, if this is indeed the problem. Any guidance would be appreciated. Thanks, Ed -- 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] weird axis tickmark format
I'm plotting values that cover a very small range with a relatively large base, e.g. 375.0001 375.00025 375.0002 ... In practice, the data series hovers at a single value for several hundred elements in a row, then fluctuates slightly. Initially matplotlib does what I expect, and the Y-axis ticks are labeled 373, 374, 376, 376, etc. Once the small fluctuations are plotted, however, it switches to showing relative values, with the absolute reference point above the plot, as in the attached image. This is needlessly confusing - is there a way to prevent such behavior? thanks, Nat attachment: plot.png-- 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] weird axis tickmark format
On 11/29/2011 01:29 PM, Nat Echols wrote: I'm plotting values that cover a very small range with a relatively large base, e.g. 375.0001 375.00025 375.0002 ... In practice, the data series hovers at a single value for several hundred elements in a row, then fluctuates slightly. Initially matplotlib does what I expect, and the Y-axis ticks are labeled 373, 374, 376, 376, etc. Once the small fluctuations are plotted, however, it switches to showing relative values, with the absolute reference point above the plot, as in the attached image. This is needlessly confusing - is there a way to prevent such behavior? thanks, Nat If you are using mpl 1.0 or later, try pyplot.ticklabel_format(useOffset=False) It is also available as an Axes method. Eric -- 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 -- 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] Relpos only works once when using FancyArrow for annotation
On Mon, Nov 28, 2011 at 10:49 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote: This is a bug. In the current implementation, annotate has a side-effect that modifies the arrowprops dictionary. For a future reference, this should now be fixed in the v1.1.x branch which also has been merged into the master branch. https://github.com/matplotlib/matplotlib/commit/b3a2ab77c89fdb3ab860edeb1a781b5307347070 Regards, -JJ -- 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