Skip to content

Conversation

ErwanAliasr1
Copy link
Collaborator

Some tweaks to improve hwgraph rendering

@ErwanAliasr1 ErwanAliasr1 self-assigned this Sep 10, 2025
@ErwanAliasr1 ErwanAliasr1 requested a review from anisse September 10, 2025 15:47
Copy link
Contributor

@anisse anisse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in commit message: too adjascents -> two adjacents

@anisse
Copy link
Contributor

anisse commented Sep 10, 2025

Otherwise LGTM.

@ErwanAliasr1 ErwanAliasr1 force-pushed the updates branch 3 times, most recently from 20f4f09 to ef02412 Compare September 12, 2025 17:35
hwgraph command lines could be long.
Reproducing the same graphs over time become almost impossible without
reversing the type of graphs, titles & events.

This commit simply saves the actual command line to a "cmdline" file so
anyone can execute hwgraph again.

Two tricks here :
- the program name (argv[0]) is replaced by hwgraph to remove the full
  path, which is user specific
- the use of shlex to save quotes around some arguments like the title.

Signed-off-by: Erwan Velu <[email protected]>
Some graphs uses two y-axis to compare different metrics
like "fan speed vs thermal".

A bug was found were these graphs didn't rotate the x-label while the
single axis graphs were fine. As a consequence, x-ticks labels colide
making graphs nearly unreadable.

To create a second y-axis, the "self.ax.twinx()" call is used.
As a consequence, a second x-axis is also created and it seems that
plt.xticks() was not rotating the two x-axis.

As per some internet readings, the good way of rotating xlabels is to
use the plt.setp() call proposed in this patch.

As a result, both graphs types have their x-labels now properly rotated.

Source: https://stackoverflow.com/questions/50596756/rotate-x-axis-labels-of-subplots-with-twinx
Signed-off-by: Erwan Velu <[email protected]>
When plotting several events,
- initial 5 colors were not enough: too much cycling
- too much transparent : it's hard to see where events starts/stops

This commit:
- switch to a 9-color list that could be circled without visual issues:
  two adjascents colors can't be cycled unless they seems merged
- increase alpha to 20% so event blocks are more visible

Signed-off-by: Erwan Velu <[email protected]>
// Variable names
The current code is not exposing units in time variable names.
This makes the proof reading of the code being difficult.
This commit is adding a time suffix on time variables like:
_s  : for seconds
_ms : for milliseconds
-ns : for nanoseconds
i.e end_of_run become end_of_run_ns

// Documentation
The short inline documentation mentionned "stime" while no variable have
that name.
The documentation is update to use sleep_time_ns instead of stime.

// Removing get_monotonic() helper
As the helper is only using time.monotonic_ns(), let's remove the
function and let's call the function directly. This is also making the
return unit more explicit.

Signed-off-by: Erwan Velu <[email protected]>
The current legends are inside the box preventing reading some of the
values.

This commit is fixing in space the two legends to ensure it's outside of
the graphs.

Signed-off-by: Erwan Velu <[email protected]>
It's usually hard to read some metrics and understand their actual
values.

This patch is about adding some statistics after each legend.

The proposed format is : <name> [min(); mean(); stddev(); max()]

This formating will the main statistics indicator for every items
plotted in the graph.

Signed-off-by: Erwan Velu <[email protected]>
When rendering units in percent, using 100% is problematic since this
will be the maximum value of the graph.

If the measured value is 100%, the graph will mix data and the frame of
the graph making the data unreadable.

This commit increase the max value to 110, so a 100% will be graphed
below the max possible value, making it readable.

Signed-off-by: Erwan Velu <[email protected]>
@ErwanAliasr1 ErwanAliasr1 merged commit 33927ed into main Oct 17, 2025
4 checks passed
@ErwanAliasr1 ErwanAliasr1 deleted the updates branch October 17, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants