Skip to content
Snippets Groups Projects
Verified Commit e010ecc3 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

put grid in background

parent c189fd5c
Branches
No related tags found
No related merge requests found
......@@ -135,6 +135,7 @@ if __name__ == "__main__":
multi_bar_parser.add_argument("--log-scale", action="store_true")
multi_bar_parser.add_argument("--grid", action="store_true")
multi_bar_parser.add_argument("--minor-grid", action="store_true")
multi_bar_parser.add_argument("--grid-behind", action="store_true")
common_options = [
{
......@@ -220,6 +221,7 @@ if __name__ == "__main__":
log_scale=args.log_scale,
grid=args.grid,
minor_grid=args.minor_grid,
grid_behind=args.grid_behind,
style=json.loads(args.style),
)
......
......@@ -86,6 +86,7 @@ def multi_bar(
log_scale: bool = False,
grid: bool = False,
minor_grid: bool = False,
grid_behind: bool = False,
style: dict = {},
) -> matplotlib.figure.Figure:
if labels_locations is None:
......@@ -102,14 +103,17 @@ def multi_bar(
fig, ax = plt.subplots(layout=plot_layout)
zorder = 3 if grid_behind else None
for i, (attribute, measurement) in enumerate(measurements.items()):
rects = ax.bar(labels_locations + width * i, measurement, width, label=attribute, **style.get(attribute, {}))
rects = ax.bar(labels_locations + width * i, measurement, width, zorder=zorder, label=attribute, **style.get(attribute, {}))
ax.bar_label(rects, padding=3)
ax.set_ylabel(y_label)
ax.set_title(title)
if log_scale:
ax.set_yscale('log')
if (grid or minor_grid) and grid_behind:
ax.yaxis.grid(zorder=0)
if grid:
ax.yaxis.grid(True, which="major")
if minor_grid:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment