Skip to content

Commit

Permalink
Add --log-count option to plot_histogram.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp authored and David Peter committed Apr 17, 2023
1 parent 7684efd commit 77e7b6c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions scripts/plot_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -45,14 +48,23 @@
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"]})

plt.xlabel("Time [s]")
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:
Expand Down

0 comments on commit 77e7b6c

Please sign in to comment.