Skip to content
Myr

add: legend modification parameters and output DPI (#758)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* add: legend modification parameters and output DPI This commit adds a CLI parameter to plot_histogram in order to position the legend of the plot on the diagram. It also defines the output DPI for the plot to 600 dpi. Plot_progression gets a CLI paramter to add a custom label and to overwrite the default one. ---------

authored by Spreadcat · committed by GitHub · parent 824aafb · Browse files · 1 file+14 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: dbv <jt@dbv03.linpro.no>
  • Co-authored-by: dbv <spreadcat.github@micronarrativ.org>

Diff stats

1 file+14 added−2 removed

  • other:+14 added−2 removed

1 file+14 added−2 removed

modified:scripts/plot_histogram.py+14 added-2 removed
4 unmodified lines
5import argparse6import json7import numpy as np8import matplotlib.pyplot as plt9import matplotlib.font_manager1011parser = argparse.ArgumentParser(description=__doc__)12parser.add_argument("file", help="JSON file with benchmark results")13parser.add_argument("--title", help="Plot title")
1 unmodified line
15 "--labels", help="Comma-separated list of entries for the plot legend"16)17parser.add_argument("--bins", help="Number of bins (default: auto)")18parser.add_argument(19 "--legend-location", help="Location of the legend on plot (default: upper center)",20 choices=["upper center", "lower center", "right", "left", "best", "upper left", "upper right", "lower left", "lower right", "center left", "center right", "center"],21 default="upper center"22 )23parser.add_argument(24 "--type", help="Type of histogram (*bar*, barstacked, step, stepfilled)"25)26parser.add_argument("-o", "--output", help="Save image to the given filename.")27parser.add_argument(
24 unmodified lines
5253bins = int(args.bins) if args.bins else "auto"54histtype = args.type if args.type else "bar"5556plt.figure(figsize=(10, 5))57plt.hist(58 all_times,59 label=labels,60 bins=bins,61 histtype=histtype,62 range=(t_min, t_max),63)57plt.legend(prop={"family": ["Source Code Pro", "Fira Mono", "Courier New"]})64plt.legend(65 loc=args.legend_location,66 fancybox=True,67 shadow=True,68 prop={"size": 7, "family": ["Source Code Pro", "Fira Mono", "Courier New"]}69 )7071plt.xlabel("Time [s]")72if args.title:73 plt.title(args.title)
3 unmodified lines
77else:78 plt.ylim(0, None)7980if args.output:69 plt.savefig(args.output)81 plt.savefig(args.output, dpi=600)82else:83 plt.show()