Skip to content

2D Plots

Klaas Padeken edited this page Sep 11, 2017 · 1 revision

2D Plots

Introduction

To also plot 2D plots in your macro you need to include the DukePlotALot2D via

from DukePlotALot2D import *

Then you can initialize the plotter object the same way as a 1D plotter with the same style container object that dictates all style informations of the plot.

hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Standard', cmsPositon = "upper left", legendPosition = 'lower middle', lumi = 1000, cms = 13)
hist_style.Set_additional_text('plot dummy')

test = plotter2D(hist = histlist[0], style = hist_style)

The histogram that the 2D plotter gets is at the moment the only object that is drawn and sould be a Hist2D object. As a last step you just need to make the plot via

test.make_plot('test_name.pdf')

This plot should than look like this example

Projections

To also include projections of the 2D plot along either the x-, the y- or both axis you just need to call the functions

test.Add_y_projection(20)

and

test.Add_x_projection(20)

The argument is the width of the projected plot. If you include both projections the plot should look like this example

Additional options

If you also want to have the individual projection plots, the 2D plot and the combined version you just need to specify the individual option

test.make_plot('test_name.pdf', individual = True)

while making the plot. With this option the combined plot and all individual plots are created. You would get the two examples linked above and the two projections example 1 and example 2