From 77e7b6cd65a15da46bf8ae3e28f12dc166505d6f Mon Sep 17 00:00:00 2001 From: David Peter Date: Mon, 17 Apr 2023 22:27:28 +0200 Subject: [PATCH] Add --log-count option to plot_histogram.py --- scripts/plot_histogram.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/scripts/plot_histogram.py b/scripts/plot_histogram.py index b084defd0..9700b907e 100755 --- a/scripts/plot_histogram.py +++ b/scripts/plot_histogram.py @@ -17,15 +17,18 @@ parser.add_argument( "--type", help="Type of histogram (*bar*, barstacked, step, stepfilled)" ) -parser.add_argument( - "-o", "--output", help="Save image to the given filename." -) +parser.add_argument("-o", "--output", help="Save image to the given filename.") parser.add_argument( "--t-min", metavar="T", help="Minimum time to be displayed (seconds)" ) parser.add_argument( "--t-max", metavar="T", help="Maximum time to be displayed (seconds)" ) +parser.add_argument( + "--log-count", + help="Use a logarithmic y-axis for the event count", + action="store_true", +) args = parser.parse_args() @@ -45,7 +48,11 @@ histtype = args.type if args.type else "bar" plt.hist( - all_times, label=labels, bins=bins, histtype=histtype, range=(t_min, t_max), + all_times, + label=labels, + bins=bins, + histtype=histtype, + range=(t_min, t_max), ) plt.legend(prop={"family": ["Source Code Pro", "Fira Mono", "Courier New"]}) @@ -53,6 +60,11 @@ if args.title: plt.title(args.title) +if args.log_count: + plt.yscale("log") +else: + plt.ylim(0, None) + if args.output: plt.savefig(args.output) else: