Plotting two TH1D together

Hi there!

I have a root file (“data.root”) with two TH1D files on it:

“ICRC_V2_hists/Cos theta/data” and "“ICRC_V2_hists/Cos theta/MC”


I have made this script to plot the two histograms together:

import ROOT
import numpy as np
import uproot
import matplotlib.pyplot as plt

f =“data.root”)

fig, ax = plt.subplots()

h_data = f[“ICRC_V2_hists/Cos theta/data”].to_numpy()
h_MC = f[“ICRC_V2_hists/Cos theta/MC”].to_numpy()

hists = [h_MC, h_data]

for h in hists :

** ax.hist(h[1][:-1],**
** bins = h[1],**
** weights = h[0],**
** histtype = ‘step’,**
** zorder=10)**

ax.set_ylabel(‘Rate [Hz]’)


But the result is something like:


What I want to do is to give this step format for “MC” but to keep the original dataformat for “data” (I meen, not a bar hist but points with errorbars, as seen above).

How can I do it?

Thanks in advance!

The two separated plots are clearly produced by ROOT graphics but the second plot (grouping the two histograms) seems to be produced by mathplotlib . So that’s not a ROOT question but more a mathplotlib one. Unless you are willing to produce the second plot using ROOT graphics and in that case you can simply do: