Skip to content
Snippets Groups Projects

use better names in `plot.py`

Merged STEVAN Antoine requested to merge plot-script-better-names into main
1 file
+ 10
10
Compare changes
  • Side-by-side
  • Inline
+ 10
10
@@ -55,7 +55,7 @@ default values have been chosen:
# see [`HELP`]
def plot(
data,
graphs,
title: str,
x_label: str,
y_label: str,
@@ -66,10 +66,10 @@ def plot(
):
fig, ax = plt.subplots(layout=plot_layout)
for group in data:
xs = [x["x"] for x in group["items"]]
ys = [x["measurement"] for x in group["items"]]
zs = [x["error"] for x in group["items"]]
for g in graphs:
xs = [x["x"] for x in g["items"]]
ys = [x["measurement"] for x in g["items"]]
zs = [x["error"] for x in g["items"]]
down = [y - z for (y, z) in zip(ys, zs)]
up = [y + z for (y, z) in zip(ys, zs)]
@@ -81,15 +81,15 @@ def plot(
"linewidth": None,
}
alpha = 0.3
if "style" in group:
custom_style = group["style"]
if "style" in g:
custom_style = g["style"]
style["color"] = custom_style.get("color", None)
style["marker"] = custom_style.get("line", {}).get("marker", style["marker"])
style["linestyle"] = custom_style.get("line", {}).get("type", style["linestyle"])
style["linewidth"] = custom_style.get("line", {}).get("width", style["linewidth"])
alpha = custom_style.get("alpha", alpha)
ax.plot(xs, ys, label=group["group"], **style)
ax.plot(xs, ys, label=g["group"], **style)
if style["color"] is None:
ax.fill_between(xs, down, up, alpha=alpha)
else:
@@ -119,7 +119,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter
)
parser.add_argument("data", type=str, help=f"the actual data to show in a multibar plot\n\n{HELP}"
parser.add_argument("graphs", type=str, help=f"the list of graphs to plot\n\n{HELP}"
)
parser.add_argument("--title", "-t", type=str, help="the title of the plot")
parser.add_argument("--x-label", "-x", type=str, help="the x label of the plot")
@@ -133,7 +133,7 @@ if __name__ == "__main__":
plot_layout = "constrained" if args.fullscreen else None
plot(
json.loads(args.data),
json.loads(args.graphs),
args.title,
args.x_label,
args.y_label,
Loading