Multiple data can be plotted on the same graph with different y axis scales. Below is a sample code where data is pulled from a csv gtab file and loaded into pandas dataframe structures. Matplotlib is then used to plot four sets of data.
import pandas as pd
import matplotlib.pyplot as plt
import scipy.fftpack
import numpy as np
from pandas import DataFrame
nautiData = pd.read_csv(r'./NC_2P8m_150924083719_roll valv not working 3.bin.tab', delimiter='\t')
#print list(nautiData.columns.values)
#print(nautiData)
fig, ax = plt.subplots()
# Twin the x-axis twice to make independent y-axes.
# Make 4 axis for 4 plots with different independent y axis scales.
axes = [ax, ax.twinx(), ax.twinx(), ax.twinx()]
# Make some space on the right side for the extra y-axis.
fig.subplots_adjust(right=0.75)
for axis_index in range(len(axes)):
if axis_index >= 2:
# Move the last y-axis spine over to the right by 20% of the width of the axes
axes[axis_index].spines['right'].set_position(('axes', 1.0 + (axis_index-1) * 0.1))
# To make the border of the right-most axis visible, we need to turn the frame
# on. This hides the other plots, however, so we need to turn its fill off.
axes[axis_index].set_frame_on(True)
axes[axis_index].patch.set_visible(False)
# And finally we get to plot things...
colors = ('Green', 'Red', 'Blue', 'yellow')
logtime = nautiData['logtime']
data = [nautiData['rollactive']]
data.append(nautiData['rrdbp'])
data.append(nautiData['rldbp'])
data.append(nautiData['rdbx'])
units = ['mA', 'bar', 'bar', 'mm']
axes[0].plot(logtime, data1, marker='', linestyle='-', color=colors[0])
axes[1].plot(logtime, data2, marker='', linestyle='-', color=colors[1])
axes[2].plot(logtime, data3, marker='', linestyle='-', color=colors[2])
axes[3].plot(logtime, data4, marker='', linestyle='-', color=colors[3])
for axis_index in range(len(axes)):
axes[axis_index].set_ylabel('%s %s' % (data[axis_index].name, units[axis_index]), color=colors[axis_index])
axes[axis_index].tick_params(axis='y', colors=colors[axis_index])
axes[0].set_xlabel('time seconds')
plt.show()