-
Notifications
You must be signed in to change notification settings - Fork 11
Second y Axis
Klaas Padeken edited this page Sep 11, 2017
·
1 revision
At the beginning, you need two histograms to be plottet on a different scale. In the example, there is on histogram for the TriggerRate (hist1) and one histogram for the signal efficiency (hist2). Both histograms have the same x-Axis that is defined with hist1. For the y-Axis of the second histogram, there are three values: histaxis_logy (default = 'False'), histaxis_ymin (default = -1) and histaxis_ymax (default = -1). The first histogram for the second axis is important since it defines the color of the axis title which is the same as the line color of the first histogram. To include the second axis, you have to fill the array hist_axis = [] as shown in the example:
#!/bin/env python
from DukePlotALot import *
import style_class as sc
from rootpy.io import root_open
def main():
# Open a File that includes the Plot for the standard axis
TestFile = root_open('Dumping_TriggerRate.root')
hist1 = TestFile.hMuonTrig.Clone(title='Trigger Rate')
# Add the options for the Plot on the standard axis
hist1.fillstyle = '0'
hist1.fillcolor = 'red'
hist1.linecolor = 'black'
hist1.linewidth = 1
# The xaxis infomation will also be used for the second axis
hist1.xaxis.SetTitle('Mass (GeV)')
# Open a File that includes the Plot for the second axis
TestFile2 = root_open('Dumping_TriggerEfficiency.root')
hist2 = TestFile2.hMuonEff.Clone(title='Efficiency')
# The linecolor of the first Plot for the second axis
# is used to define the title color (here 'red')
hist2.linecolor = 'red'
hist2.yaxis.SetTitle('Efficiency (%)')
hist_style = sc.style_container(style = 'CMS', useRoot = False)
# Only hist_axis (default = []) is used for the second axis
# sig, hist, data_hist are all plotted on the first axis
test = plotter(sig = [hist1], hist_axis = [hist2], style=hist_style)
# Plot it!
test.make_plot('TwoAxes.pdf')
return 42
main()If everything works, the result looks like: TwoAxis.pdf