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