MCPcopy Create free account
hub / github.com/Klipper3d/klipper / plot_accel

Function plot_accel

scripts/graph_accelerometer.py:39–65  ·  view source on GitHub ↗
(datas, lognames)

Source from the content-addressed store, hash-verified

37######################################################################
38
39def plot_accel(datas, lognames):
40 fig, axes = matplotlib.pyplot.subplots(nrows=3, sharex=True)
41 axes[0].set_title("\n".join(wrap(
42 "Accelerometer data (%s)" % (', '.join(lognames)), MAX_TITLE_LENGTH)))
43 axis_names = ['x', 'y', 'z']
44 for data, logname in zip(datas, lognames):
45 if isinstance(data, shaper_calibrate.CalibrationData):
46 raise error("Cannot plot raw accelerometer data using the processed"
47 " resonances, raw_data input is required")
48 first_time = data[0, 0]
49 times = data[:,0] - first_time
50 for i in range(len(axis_names)):
51 avg = data[:,i+1].mean()
52 adata = data[:,i+1] - data[:,i+1].mean()
53 ax = axes[i]
54 label = '\n'.join(wrap(logname, 60)) + ' (%+.3f mm/s^2)' % (-avg,)
55 ax.plot(times, adata, alpha=0.8, label=label)
56 axes[-1].set_xlabel('Time (s)')
57 fontP = matplotlib.font_manager.FontProperties()
58 fontP.set_size('x-small')
59 for i in range(len(axis_names)):
60 ax = axes[i]
61 ax.grid(True)
62 ax.legend(loc='best', prop=fontP)
63 ax.set_ylabel('%s accel' % (axis_names[i],))
64 fig.tight_layout()
65 return fig
66
67
68######################################################################

Callers 1

mainFunction · 0.85

Calls 2

plotMethod · 0.80
errorClass · 0.70

Tested by

no test coverage detected