from pyhs3.distributions.histfactory.samples import Sample
from pyhs3.axes import Axes

# Create multiple samples
signal = Sample(
    name="Signal",
    data={"contents": [5.0, 8.0, 12.0, 7.0], "errors": [2.0, 2.5, 3.0, 2.3]}
)

background = Sample(
    name="Background",
    data={"contents": [15.0, 18.0, 14.0, 16.0], "errors": [3.5, 4.0, 3.7, 3.9]}
)

# Common axes for both samples
axes = Axes([{"name": "observable", "min": 0.0, "max": 4.0, "nbins": 4}])

# Convert and plot both
h_signal = signal.to_hist(axes)
h_background = background.to_hist(axes)

h_signal.plot(histtype="step", linewidth=2, label=signal.name)
h_background.plot(histtype="step", linewidth=2, label=background.name)
plt.xlabel("Observable")
plt.ylabel("Events")
plt.legend()
plt.title("Signal vs Background")