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

Function plot_compare_frequency

scripts/graph_accelerometer.py:136–157  ·  view source on GitHub ↗
(datas, lognames, max_freq, axis)

Source from the content-addressed store, hash-verified

134 return fig
135
136def plot_compare_frequency(datas, lognames, max_freq, axis):
137 fig, ax = matplotlib.pyplot.subplots()
138 ax.set_title('Frequency responses comparison')
139 ax.set_xlabel('Frequency (Hz)')
140 ax.set_ylabel('Power spectral density')
141
142 for data, logname in zip(datas, lognames):
143 calibration_data = calc_freq_response(data, max_freq)
144 freqs = calibration_data.freq_bins
145 psd = calibration_data.get_psd(axis)[freqs <= max_freq]
146 freqs = freqs[freqs <= max_freq]
147 ax.plot(freqs, psd, label="\n".join(wrap(logname, 60)), alpha=0.6)
148
149 ax.xaxis.set_minor_locator(matplotlib.ticker.AutoMinorLocator())
150 ax.yaxis.set_minor_locator(matplotlib.ticker.AutoMinorLocator())
151 ax.grid(which='major', color='grey')
152 ax.grid(which='minor', color='lightgrey')
153 fontP = matplotlib.font_manager.FontProperties()
154 fontP.set_size('x-small')
155 ax.legend(loc='best', prop=fontP)
156 fig.tight_layout()
157 return fig
158
159# Plot data in a "spectrogram colormap"
160def plot_specgram(data, logname, max_freq, axis):

Callers 1

mainFunction · 0.85

Calls 3

calc_freq_responseFunction · 0.85
get_psdMethod · 0.80
plotMethod · 0.80

Tested by

no test coverage detected