From c61be73b78b960ecf655658f6e37687dca7fe660 Mon Sep 17 00:00:00 2001 From: Grzegorz Latosinski Date: Wed, 7 Sep 2022 18:27:37 +0200 Subject: [PATCH] [#37192] graph: Added displaying hours and minutes in TXT plot Signed-off-by: Grzegorz Latosinski --- graph.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/graph.py b/graph.py index 119f06c..824f66e 100644 --- a/graph.py +++ b/graph.py @@ -347,6 +347,8 @@ def create_ascii_plot( xdata = np.array(xdata[start:], copy=True) ydata = np.array(ydata[start:], copy=True) + xdata = [datetime.datetime.fromtimestamp(x).strftime('%H:%M:%S') for x in xdata] + if trimxvalues: minx = min(xdata) xdata = [x - minx for x in xdata] @@ -371,8 +373,8 @@ def create_ascii_plot( if y_range is not None: plotext.ylim(y_range[0], y_range[1]) plotext.title(title) - plotext.xlabel(xtitle) - plotext.ylabel(ytitle) + plotext.xlabel(xlabel) + plotext.ylabel(ylabel) plotext.canvas_color(canvas_color) plotext.axes_color(axes_color) plotext.ticks_color(ticks_color) @@ -435,15 +437,15 @@ def ascii_graph(session, fname='plot.png'): render_ascii_plot( titles, - ["time"]*3, - ["s"]*3, + ["time", "time", "time"], + [None, None, None], y_titles, [None, None, None], xdata_to_int, ydata, x_range=(0, 160), y_range=(0, 100), - trimxvalues=True, + trimxvalues=False, skipfirst=False, switchtobarchart=True, figsize=(90, 70)