general_bar_plot#
General bar plot comparing multiple metrics for each category with consistent colors and hatching.
π₯ Arguments#
Name |
Type |
Required |
Description |
|---|---|---|---|
df |
pd.DataFrame |
β |
DataFrame containing the category column and one or more metric columns. |
category_column |
str |
β |
Column name for the x-axis categories (e.g., βGroupβ, βConditionβ). |
figsize |
tuple |
β |
Figure size. Default: (12, 7). |
xlabel |
str |
β |
Label for x-axis. |
ylabel |
str |
β |
Label for y-axis. |
title |
str |
β |
Title of the plot. |
legend_loc |
str |
β |
Legend location. Default: βupper rightβ. |
bar_width |
float |
β |
Width of bars. Default: 0.25. |
color_map |
Dict[str, str] |
β |
Map from metric name to color. |
style_map |
Dict[str, str] |
β |
Map from metric name to hatch style. |
save |
str |
β |
Base filename to save PNG and PDF. |
π¦ Example Output#
Click to show example code
import pandas as pd
from swizz import plot
import matplotlib.pyplot as plt
df = pd.DataFrame({
"Condition": ["No FTz", "FTz"],
"Reward": [1.0, 1.2],
"Goal": [0.7, 0.9],
})
fig, ax = plot("general_bar_plot",
df=df,
category_column="Condition",
ylabel="Avg Value",
title="Comparison of Reward and Goal",
color_map={"Reward": "tab:blue", "Goal": "tab:orange"},
style_map={"Reward": "/", "Goal": "\\"},
bar_width=0.3,
save="general_bar_plot"
)
plt.show()