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

Function plot_mcu_frequency

scripts/graphstats.py:220–248  ·  view source on GitHub ↗
(data, mcu)

Source from the content-addressed store, hash-verified

218 return fig
219
220def plot_mcu_frequency(data, mcu):
221 all_keys = {}
222 for d in data:
223 all_keys.update(d)
224 graph_keys = { key: ([], []) for key in all_keys
225 if key in ("freq", "adj") }
226 for d in data:
227 st = datetime.datetime.utcfromtimestamp(d['#sampletime'])
228 for key, (times, values) in graph_keys.items():
229 val = d.get(key)
230 if val not in (None, '0', '1'):
231 times.append(st)
232 values.append(float(val))
233
234 # Build plot
235 fig, ax1 = matplotlib.pyplot.subplots()
236 ax1.set_title("MCU '%s' frequency" % (mcu,))
237 ax1.set_xlabel('Time')
238 ax1.set_ylabel('Frequency')
239 for key in sorted(graph_keys):
240 times, values = graph_keys[key]
241 ax1.plot_date(times, values, '.', label=key)
242 fontP = matplotlib.font_manager.FontProperties()
243 fontP.set_size('x-small')
244 ax1.legend(loc='best', prop=fontP)
245 ax1.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%H:%M'))
246 ax1.yaxis.set_major_formatter(matplotlib.ticker.FormatStrFormatter('%d'))
247 ax1.grid(True)
248 return fig
249
250def plot_temperature(data, heaters):
251 fig, ax1 = matplotlib.pyplot.subplots()

Callers 1

mainFunction · 0.85

Calls 2

updateMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected