Re: [Matplotlib-users] matplotlib slow compared to gnuplot?
It looks like you are storing your source data in a python list. Matplotlib runs much faster if you store your data using a numpy array instead. I'm no expert, but it certianly sped up my graph drawing. -Tom Message: 5 Date: Wed, 11 Nov 2009 08:53:58 -0600 From: Mike Anderson mbander...@wisc.edu Subject: [Matplotlib-users] matplotlib slow compared to gnuplot? To: matplotlib-users@lists.sourceforge.net Message-ID: ae4d4739-44be-43f2-9e56-daedbe990...@wisc.edu Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Hi all, Previously I was a user of gnuplot but have been giving matplotlib a try. One thing I've run in to right away is that matplotlib appears to be significantly slower. A script to produce a dozen plots was taking me ~1 second with gnuplot, and now takes me ~18 seconds with matplotlib. I'm curious if anyone knows how to speed things up. To figure out what is taking most of the time, I've used cProfile and pstats and below is the top 15 functions taking the most time. (note: plotStackedJobsVsTime is my function that uses matplotlib.) My script, for the curious, is at http://www.hep.wisc.edu/cms/comp/routerqMonitor/prodJobMonitorPlots_matplotlib.py and produces these plots: http://www.hep.wisc.edu/cms/comp/routerqMonitor/index.html Any hints at what I can do to speed up my script? Or is it out of my hands because it's all in matplotlib? Thanks for any help, Mike -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to make little sparklines
Hi I was asked off list how I created the little sparklines using Matplotlib. There are two ways I create these: The live graphs on the demo page (http://your.gridspy.co.nz/powertech/) are created by a great little jquery app (so yeah, not matplotlib): http://omnipotent.net/jquery.sparkline/ To get the data to the browser in order to render the sparkline, you will need some sort of mechanism similar to Ajax (or at least a form of it) called Comet. There is a great tutorial on using orbited for this here http://cometdaily.com/2008/10/10/scalable-real-time-web-architecture-part-2-a-live-graph-with-orbited-morbidq-and-jsio/ If any of you need more help doing that, I am happy to provide some source code examples. If instead, you want to create static line graphs using matplotlib such as those on this page: http://your.gridspy.co.nz/powertech/history/04Nov2009.htm http://your.gridspy.co.nz/powertech/graph/tiny/3-3-04Nov2009.png?c=2 (an example) To render static sparklines I use the following matplot lib code: def render_simple_line(sensors, resolution = 'hour', span = 1, start=None, end=None, fig=None, column=0): Builds a figure that shows the given sensors at the given resolution and span in the given time period. if fig is None: fig=Figure() fig.set_facecolor('white') fig.set_edgecolor('white') axes = fig.add_axes([0.00,0.00,1.0,1.0], axisbg='w', frame_on=False) axes.set_xticks([]) axes.set_yticks([]) axes.set_axis_off() if start is None: start = datetime.datetime.now() if end is None: end = start + datetime.timedelta(days=1) first_date = start.strftime('%Y-%m-%d') last_date = end.strftime('%Y-%m-%d') desc = [(mean, pk) for pk in sensors] np_table = data_table_matrix(desc, resolution, first_date, last_date, span ) #note that np_table[0] is datetime objects and [1] is data if np_table.size == 0: return None #replace nulls with 0 np_table[1:][np_table[1:] == np.array([None])] = 0 #replace -ve values np_table[1:][np_table[1:] np.array([0])] = 0 axes.xaxis.set_major_formatter(DateFormatter('%H')) fig.autofmt_xdate() base = np.zeros(np_table.shape[1]) color = color_list[column % len(color_list)][1] axes.fill_between(np_table[0], base, np_table[column + 1], facecolor = color) return fig I pass fig in so it is easy to pass a figure from the ipython console, since ipython makes special figures that are interactive. -Tom PS: Dan - I replied to your email directly but it bounced. -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to make little sparklines
Hi I was asked off list how I created the little sparklines using Matplotlib. There are two ways I create these: The live graphs on the demo page (http://your.gridspy.co.nz/powertech/) are created by a great little jquery app (so yeah, not matplotlib): http://omnipotent.net/jquery.sparkline/ To get the data to the browser in order to render the sparkline, you will need some sort of mechanism similar to Ajax (or at least a form of it) called Comet. There is a great tutorial on using orbited for this here http://cometdaily.com/2008/10/10/scalable-real-time-web-architecture-part-2-a-live-graph-with-orbited-morbidq-and-jsio/ If any of you need more help doing that, I am happy to provide some source code examples. If instead, you want to create static line graphs using matplotlib such as those on this page: http://your.gridspy.co.nz/powertech/history/04Nov2009.htm http://your.gridspy.co.nz/powertech/graph/tiny/3-3-04Nov2009.png?c=2 (an example) To render static sparklines I use the following matplot lib code: def render_simple_line(sensors, resolution = 'hour', span = 1, start=None, end=None, fig=None, column=0): Builds a figure that shows the given sensors at the given resolution and span in the given time period. if fig is None: fig=Figure() fig.set_facecolor('white') fig.set_edgecolor('white') axes = fig.add_axes([0.00,0.00,1.0,1.0], axisbg='w', frame_on=False) axes.set_xticks([]) axes.set_yticks([]) axes.set_axis_off() if start is None: start = datetime.datetime.now() if end is None: end = start + datetime.timedelta(days=1) first_date = start.strftime('%Y-%m-%d') last_date = end.strftime('%Y-%m-%d') desc = [(mean, pk) for pk in sensors] np_table = data_table_matrix(desc, resolution, first_date, last_date, span ) #note that np_table[0] is datetime objects and [1] is data if np_table.size == 0: return None #replace nulls with 0 np_table[1:][np_table[1:] == np.array([None])] = 0 #replace -ve values np_table[1:][np_table[1:] np.array([0])] = 0 axes.xaxis.set_major_formatter(DateFormatter('%H')) fig.autofmt_xdate() base = np.zeros(np_table.shape[1]) color = color_list[column % len(color_list)][1] axes.fill_between(np_table[0], base, np_table[column + 1], facecolor = color) return fig I pass fig in so it is easy to pass a figure from the ipython console, since ipython makes special figures that are interactive. -Tom PS: Dan - I replied to your email directly but it bounced. -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Gridspy dashboard - Web based Matplotlib
Hi. I would like to introduce my usage of Matplotlib... Gridspy provides you with an interactive view of resource usage in your building. It gives you hard data on your consumption patterns and helps you to make informed decisions. ... The Gridspy allows you to access and monitor your consumption patterns in real-time using a standard web browser on your PC, laptop or mobile phone. The data is presented in high resolution and updated each second as you watch. The moment a light is turned on in your house, you can see the change on your Gridspy dashboard from across the room or across the planet. We use Matplotlib to prepare graphs in PNG format that form an essential part of our dashboard here (it loads nice and fast, trust me): http://your.gridspy.co.nz/powertech/ The blog discusses our Python Twisted backend, and other stuff: http://blog.gridspy.co.nz/ Finally you can follow my progress as I take this product to market on twitter: http://www.twitter.com/gridspy/ It has been a fantastic system to work with, and it was easy to generate beautiful and meaningful graphs. Thanks to everyone who has made this possible! What is everyone else working on? -Tom -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users