[Matplotlib-users] Data representation improvements

Jon Roadley-Battin jon.roadleybattin at gmail.com
Sun Jul 31 16:08:05 EDT 2016


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.

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160731/c42e9760/attachment.html>


More information about the Matplotlib-users mailing list