I have working code to generate plots showing x,y,z values for three parameters from an accelerometer, with side-by-side line and 3D plots for each:
from mpl_toolkits import mplot3d
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#code here loads data into a dataframe df
fig = plt.figure(figsize=(10,8))
fig.suptitle(filename, fontsize=12)
for p in ('accel','angle','avelo')
i += 1
ax = fig.add_subplot(3, 2, i)
ax.plot(idx,df[p,'x'], label = "x")
ax.plot(idx,df[p,'y'], label = "y")
ax.plot(idx,df[p,'z'], label = "z")
ax.set_ylabel(p)
ax.legend(loc="best")
i += 1
ax = fig.add_subplot(3,2,i,projection='3d')
ax.plot3D(df[p,'x'],df[p,'y'],df[p,'z'],'black')
ax.scatter(df[p]['x'][0],df[p]['y'][0],df[p]['z'][0], c='green', marker='o', s=50)
ax.scatter(df[p]['x'].iloc[-1],df[p]['y'].iloc[-1],df[p]['z'].iloc[-1], c='red', marker='x', s=50)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.subplots_adjust(left=0.1,
bottom=0.1,
right=0.9,
top=0.9,
wspace=0.4,
hspace=0.1)
plt.show()
I want to make the line plots twice as wide as they are by default. Is there some way to do this with the existing add_subplot approach or do I have to rework the code to set up the plots with plt.subplots? All the examples I find assume the latter.