Problem with xlabels not appearing on histograms that include pull plots when using a ROOT script with associated dictionaries

Dear experts,

I’m facing an issue while trying to generate histograms with pullplot in ROOT using a script that utilizes two dictionaries: global.yaml and histos2dta.yaml. I can generate the histograms correctly, but I’m unable to get the xlabels to appear on the histograms that have pullplot.

I have attached to this post the script I’m using (script.C) and the two mentioned dictionaries (global.yaml and histos2dta.yaml). They define histogram parameters and general configurations.

The specific problem is that, even though I define the xlabels correctly in both the dictionaries and the script, when I use the function to generate the pullplot, the xlabels are not displayed on the resulting plot. I have checked the ROOT documentation and reviewed the code, but I haven’t been able to identify what is causing this behavior.

My gitlab address is rmacedod and the file is on master. As I’m new to the forum, I can’t upload the file or send the link.

Hi Rafael,

Thanks for the post and welcome to the ROOT Community!

Could you write here in this post a minimal code snippet that reproduces your problem? The information is too terse to even start the guesswork at this point I fear.

Cheers,
Danilo

For example, with the following dictionary, my plot displays the pullplot and, even with the command to display an xlabel, nothing appears.

amu:
#ylabel: “teste amu y primeira ordem”
#xlabel: “teste amu x primeira ordem”
xlabel: “[GeV]”
ylabel: “Number of events”
#linecolor: 1
#bining: 1
amu_pT:
pullplot: True
linecolor: 1
#pullylabel: “whatever”
linewidth: 2
erroroff: True
bining: 1
pullylabel: “Data / MC”
header: “amu_pT”
#logscale: True
#ylabel: “teste amu y segudna ordem”
Histograms:
rec_amuNoWt:
fillcolor: 633
linecolor: 633
fillstyle: 3165
legend: “rec_amuNoWt”
#logscale: True
pull1: True
rec_amu:
fillcolor: 873
linecolor: 873
fillstyle: 3165
legend: “rec_amu”
pull2: True
#errorfillcolor: 633

In plots where pullplots do not appear, this does not happen

jets:
jet1eta:
erroroff: True
linewidth: 2
xlabel: “#eta ^{jet1}”
#pullplot: True
header: “jet1EtaIncs2thh”
bining: 1
Histograms:
tru_jet1EtaIncs2thh:
linecolor: 1
pull1: True
scatter: True
legend: “tru”
rec_jet1EtaIncs2thh:
linecolor: 633
scale: 1.35
pull2: True
legend: “rec”

This is the part of the code related to reading the xlabels:

	# ================NOW LETS READ THE XLABEL FROM THE YAML FILE =======================

	#reading the ylabel if it was just above the mais class. like below:
	"""
	jets:
		xlabel:  -> heree
		pt:
			Histograms:
	
	"""
	for k,v in dictionary1.items():
		if "xlabel" in dictionary1[k]:
			if( subclassArray[kl] in dictionary1[k]):		
				ax1.set_xlabel(dictionary1[k]["xlabel"])

	#reading the ylabel just after it was defined in the subclass:
	"""
	jets:
		pt:
		  xlabel: "here" -> here
		  Histograms:
		    rec_jet1Pt:
	"""

	for k,v in dictionary1.items():
		if( subclassArray[kl] in dictionary1[k]):
			if "xlabel" in dictionary1[k][subclassArray[kl]]:
					
				ax1.set_xlabel(dictionary1[k][subclassArray[kl]]["xlabel"])		



	#reading the xlabel if it was defined inside the histogram name.
	"""
	jets:
		xlabel:  -> heree
		pt:
			Histograms:
				rec_jet1Pt:
					xlabel: "here"  -> here
	"""
	for k,v in dictionary1.items():
		#if "ylabel" in dictionary1[k]:
			if( subclassArray[kl] in dictionary1[k]):
				for j in range(nHistograms):
					if( nameArray[j] in dictionary1[k][subclassArray[kl]]["Histograms"]):	
						if( "xlabel" in dictionary1[k][subclassArray[kl]]["Histograms"][nameArray[j]] ):	
							ax1.set_xlabel(dictionary1[k][subclassArray[kl]]["Histograms"][nameArray[j]]["xlabel"])		
	
	
	
	
	#================ END OF X LABEL READING ===========================================
	

	#seting the maximum and minimum of yaxis		
	
	for k,v in dictionary1.items():
		if( subclassArray[kl] in dictionary1[k]):
			if "ylimmax" in dictionary1[k][subclassArray[kl]]:
				ax1.set_ylim( top =  dictionary1[k][subclassArray[kl]]["ylimmax"] )						
			if "ylimmax" in dictionary1[k][subclassArray[kl]] and "ylimmin" in dictionary1[k][subclassArray[kl]]:
				ax1.set_ylim(dictionary1[k][subclassArray[kl]]["ylimmin"] , dictionary1[k][subclassArray[kl]]["ylimmax"] )
			#else:
			#	ax1.set_ylim(bottom=1.0)

	for k,v in dictionary1.items():
		if( subclassArray[kl] in dictionary1[k]):
			if "xlimmax" in dictionary1[k][subclassArray[kl]]:
				ax1.set_xlim( right =  dictionary1[k][subclassArray[kl]]["xlimmax"] )	
				try:
					ax2.set_xlim( right =  dictionary1[k][subclassArray[kl]]["xlimmax"] )
				except:
					pass	
			if "xlimmin" in dictionary1[k][subclassArray[kl]]:
				ax1.set_xlim( left =  dictionary1[k][subclassArray[kl]]["xlimmin"] )
				try:
					ax2.set_xlim( left =  dictionary1[k][subclassArray[kl]]["xlimmin"] )	
				except:
					pass														
			if "xlimmax" in dictionary1[k][subclassArray[kl]] and "xlimmin" in dictionary1[k][subclassArray[kl]]:
				ax1.set_xlim(dictionary1[k][subclassArray[kl]]["xlimmin"] , dictionary1[k][subclassArray[kl]]["xlimmax"] )
				try:
					ax2.set_xlim(dictionary1[k][subclassArray[kl]]["xlimmin"] , dictionary1[k][subclassArray[kl]]["xlimmax"] )
				except:
					pass	




	#HERE WE ARE READING THE LABELS OF THE PULL PLOT
	
	for k,v in dictionary1.items():
		if( subclassArray[kl] in dictionary1[k]):
			if "pullplot" in dictionary1[k][subclassArray[kl]]:
				if(dictionary1[k][subclassArray[kl]]["pullplot"]):

					for k,v in dictionary1.items():
						if "xlabel" in dictionary1[k]:
							if( subclassArray[kl] in dictionary1[k]):		
								ax2.set_xlabel(dictionary1[k]["xlabel"])

					#reading the ylabel just after it was defined in the subclass:
					"""
					jets:
						pt:
						xlabel: "here" -> here
						Histograms:
							rec_jet1Pt:
					"""

					for k,v in dictionary1.items():
						if( subclassArray[kl] in dictionary1[k]):
							if "xlabel" in dictionary1[k][subclassArray[kl]]:
									
								ax2.set_xlabel(dictionary1[k][subclassArray[kl]]["xlabel"])		
				
				
				
					#reading the xlabel if it was defined inside the histogram name.
					"""
					jets:
						xlabel:  -> heree
						pt:
							Histograms:
								rec_jet1Pt:
									xlabel: "here"  -> here
					"""
					for k,v in dictionary1.items():
						#if "ylabel" in dictionary1[k]:
							if( subclassArray[kl] in dictionary1[k]):
								for j in range(nHistograms):
									if( nameArray[j] in dictionary1[k][subclassArray[kl]]["Histograms"]):	
										if( "xlabel" in dictionary1[k][subclassArray[kl]]["Histograms"][nameArray[j]] ):	
											ax2.set_xlabel(dictionary1[k][subclassArray[kl]]["Histograms"][nameArray[j]]["xlabel"])