Skip to content

Reduce redundancy with keyword-argument dictionaries #77

@klieret

Description

@klieret

Example in episode 4:

fig, (ax_1, ax_2) = plt.subplots(1, 2)
fig.set_size_inches((12, 8))
ax_1.set_title("MC samples without weights")
ax_1.hist(stack_mc_list_m4l, range=ranges[0], label=mc_samples, stacked=True, bins=bins)
ax_1.set_ylabel("Events")
ax_1.set_xlabel(var_name+units)
ax_1.legend(frameon=False)
ax_2.set_title("MC samples with weights")
ax_2.hist(stack_mc_list_m4l, range=rangos[0], label=mc_samples, stacked=True, weights=stack_weights_list, bins=bines)
ax_2.set_ylabel("Events")
ax_2.set_xlabel(var_name+units)
ax_2.tick_params(which="both",direction="in",top=True,right=True, length=6, width=1)
ax_2.legend(frameon=False)

just define

hist_kwargs = dict(stacked=True, bins=bins, ...)

ax_1.hist(..., **hist_kwargs)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions