python - How to plot image data versus time with matplotlib -


i've captured set of images each column timestamped. i've concurrently sampled other signals (e.g. gyroscope data) timestamped. i'd plot these signals on 2 vertically aligned subplots share time axis.

as far understand, cannot call imshow() twice in subplot , position each image @ different location along x (they both share starting position, overlapping, , there doesn't seem setting overcome this):

import matplotlib.pyplot plt  fig, ax = plt.subplots(nrows=2, ncols=1, sharex=true)  ax[0].imshow(np.atleast_2d(i[0][0]).t, cmap=plt.cm.gray, \                             interpolation='nearest', aspect='auto') ax[0].imshow(np.atleast_2d(i[0][1]).t, cmap=plt.cm.gray, \                             interpolation='nearest', aspect='auto') 

after googling, i've found potential solution entails creating axes within top subplot, inside of can plot each column:

import matplotlib.pyplot plt  fig, ax = plt.subplots(nrows=2, ncols=1, sharex=true)  ax[0].set_ylabel('rows') imax = fig.add_axes(ax[0].get_position().min + \                 [ax[0].get_position().xmax - ax[0].get_position().xmin] + \                 [ax[0].get_position().ymax - ax[0].get_position().ymin], \                                                                 sharey=ax[0]) imax.set_ylim([i.shape[2], 0]) imax.set_axis_off() imax.imshow(np.atleast_2d(i[0][0]).t, cmap=plt.cm.gray, \                              interpolation='nearest', aspect='equal') 

although allow flexibility of positioning each column wherever can move relevant axis, it's quite bit of grunt work find relative position within image of each timestamp displayed other plots.

am missing easier way done?

you can use extent control on axis image drawn:

ax = gca() ax.imshow(rand(15,15), extent=[0, .5, 0, .5]) ax.imshow(rand(15,15), extent=[.5, 1,  .5, 1])  ax.set_xlim([0, 1]) ax.set_ylim([0, 1])  plt.draw() 

the units of extent data units.

enter image description here


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -