Hi all,
I have two 2D histograms, each with slightly different bin sizes, that I’d like to overlay. They’re slightly different in that the x scales are the same, but y scale on one of them increases twice as fast as the one on the other, but still has the same maximum and minimum.
When I overlay the histograms the cross-hatching appears through the filled histogram bins, making the plot look like a mess. Unless there is some way to make the binning scale on one axis change based on the position on the other axis (e.g. if the x axis is between -1 and 1 the y axis binning size will increment by 0.05, but if the x axis is anywhere else, the y axis binning size will increment by 0.10), I don’t have any choice but to overlay two histograms with different increments of the axes.
My question is: is there a way to stop the cross-hatching from appearing through the filled bins if I overlay two 2D histograms as described above, or is there a better way to go about what I’m trying to do?
Below is the code I use for creating the histograms initially, where hname is of type TString and m_2dhistNames is of type std:
[code] double fiveDegreesInRadians = 0.0872664626;
double tenDegreesInRadians = (fiveDegreesInRadians)*2;
int n_xbins = 80;
double xbins[81] = {-5.191, -4.889, -4.716, -4.538, -4.363, -4.191, -4.013, -3.839, -3.664, -3.489, -3.314, -3.139, -3.000, -2.650, -2.500, -2.322, -2.172, -2.043, -1.930, -1.830, -1.740, -1.653, -1.566, -1.479, -1.392, -1.305, -1.218, -1.131, -1.044, -0.957, -0.879, -0.783, -0.696, -0.609, -0.522, -0.435, -0.348, -0.271, -0.174, -0.087, 0, 0.087, 0.174, 0.271, 0.348, 0.435, 0.522, 0.609, 0.696, 0.783, 0.879, 0.957, 1.044, 1.131, 1.218, 1.305, 1.392, 1.479, 1.566, 1.653, 1.740, 1.830, 1.930, 2.043, 2.172, 2.322, 2.500, 2.650, 3.000, 3.139, 3.314, 3.489, 3.664, 3.839, 4.013, 4.191, 4.363, 4.538, 4.716, 4.889, 5.191};
int n_ybins_tenDegrees = 36;
double ybins_tenDegrees[37];
for (int i = 0; i < 37; i++) {
ybins_tenDegrees[i] = -M_PI + tenDegreesInRadians*i;
}
int n_ybins_fiveDegrees = 72;
double ybins_fiveDegrees[73];
for (int i = 0; i < 73; i++) {
ybins_fiveDegrees[i] = -M_PI + fiveDegreesInRadians*i;
}
hname = “h_energy_5degreePhi”;
m_2dhistNames[hname] = new TH2F(hname, “”, n_xbins, xbins, n_ybins_fiveDegrees, ybins_fiveDegrees);
hname = “h_energy_10degreePhi”;
m_2dhistNames[hname] = new TH2F(hname, “”, n_xbins, xbins, n_ybins_tenDegrees, ybins_tenDegrees);[/code]
I do not have any available source code on when I try to overlay them, because I’m currently just plotting the two histograms separately. However, when I try to overlay them I’m basically calling:
// First histogram
TH2->Draw("LEGO");
// Second histogram
TH2->Draw("LEGOSAME");
The resulting plot, as mentioned above, looks very ugly, as the cross-hatching from the axes appears over top of the histogram bins.
Any advice is greatly appreciated. Please let me know if I need to provide anymore information.