[Matplotlib-users] Data representation improvements

William Ray Wing wrw at mac.com
Sun Jul 31 18:11:23 EDT 2016


> On Jul 31, 2016, at 4:08 PM, Jon Roadley-Battin <jon.roadleybattin at gmail.com> wrote:
> 
> Good evening.
> 
> For some time now I have managed an application which acquires data from bespoke hardware & optionally plots upto seven channels. Matplotlib is embedded within a QT4 application & the "plotting" interface is almost fully for matplotlib.
> 
> I have managed to free up some spare time from my main role & I would like to vastly improve the representation of the data to the users in light of some in-use observation.
> 
> The data is being acquired from a motor-drive & so there is some sinus data ( the motor's currents... 50Hz, 100A peak), data like speed (mostly DC around 3000rpm with some ripple...) and then some digital flag (16bit data...)
> 
> The fixed point data are (luckily) all relatively low in magnitude ... and so plotting a 3000-value and a 100pk value is still visible, be it small amplitude BUT the moment I plot one of the digital flag registers, these dwarf the fixed-point data.
> 

Please tell us a bit more about those digital flag registers.  Are they 16 independent status flags, for example, or something more correlated?  If they really are 16 independent flags, the traditional way to deal with that sort of thing is to plot them as 16 separate strip-chart lines, with vertical values of 1 or 0.  They can be fairly close together, consume relatively little vertical plotting space, and still clearly show when one of the states has changed.

Bill


> To help with the I have provided means to "hide" channels but I was wondering if there is any better way?
> 
> I have considered 7 stacked x-y subplots but this will eat into vertical re-estate very quickly.
> 
> I have played with secondary y-axis but this equally ends up taking a lot of horizontal re-estate. 
> 
> I have considered plotting the digital registers akin to a digital vector so they are small, heightwise, plots as this will alleviate part of the concerns. 
> 
> Any advice with regards to a usable presentation 
> 
> 
> 
> Example code for multiple y-axis
> 
> import matplotlib.pyplot as plt
> from mpl_toolkits.axes_grid1 import host_subplot
> import mpl_toolkits.axisartist as AA
> import numpy as np
> 
> t = np.arange(0,1,0.00001)
> data = [5000*np.sin(t*2*np.pi*10),
> 10*np.sin(t*2*np.pi*20),
> 20*np.sin(t*2*np.pi*30),
> np.sin(t*2*np.pi*40)+5000,
> np.sin(t*2*np.pi*50)-5000,
> np.sin(t*2*np.pi*60),
> np.sin(t*2*np.pi*70),
> ]
> 
> fig = plt.figure()
> host = host_subplot(111, axes_class=AA.Axes)
> 
> axis_list = [None]*7
> for i in range(len(axis_list)):
>     axis_list[i] = host.twinx()
>     new_axis = axis_list[i].get_grid_helper().new_fixed_axis
>     axis_list[i].axis['right'] = new_axis(loc='right',
>                                                 axes=axis_list[i],
>                                                 offset=(60*i,0))
>     axis_list[i].axis['right'].toggle(all=True)
>     axis_list[i].plot(t,data[i])
> 
> plt.show()
> 
> for i in data:
>     plt.plot(t,i)
> plt.show()
> 
> 
> Yours, 
> 
> JonRB
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users



More information about the Matplotlib-users mailing list