import sys
args = sys.argv[:]
sys.argv = ['-b']
import ROOT
sys.argv = args
ROOT.gROOT.SetBatch(True)
ROOT.PyConfig.IgnoreCommandLineOptions = True
ROOT.gStyle.SetOptStat(0)
ROOT.gStyle.SetOptTitle(0)

def toX(self, pixelval):
	return float(pixelval)/(self.GetWw()*self.GetAbsWNDC())

def toY(self, pixelval):
	return float(pixelval)/(self.GetWh()*self.GetAbsHNDC())

idx = ROOT.TColor.GetFreeColorIndex()

rgb = [0.53,0.74,0.87]
tc = ROOT.TColor(idx, rgb[0], rgb[1], rgb[2])

c = ROOT.TCanvas("c","c",700,600)
c.Draw()
c.SetTopMargin   (toY(c, 40))
c.SetBottomMargin(toY(c, 85))
c.SetLeftMargin  (toX(c, 95))
c.SetRightMargin (toX(c, 25))

p = ROOT.TPad("p","p",0,0,1,1)
p.Draw()

p.SetPad(0,0,0.5,1)
p.SetTopMargin   (toY(p, 40))
p.SetBottomMargin(toY(p, 85))
p.SetLeftMargin  (toX(p, 95))
p.SetRightMargin (toX(p, 25))

p.cd()
h = ROOT.TH1F("bla", "bla", 10, 0, 10)
h.SetBinContent(1,10)
h.SetBinContent(2, 5)
h.SetBinContent(3, 4)
h.SetBinContent(4, 3)

h.SetFillStyle(1001)
h.SetFillColor(ROOT.kOrange)

h.GetXaxis().SetTitle      ("myVar")
h.GetXaxis().SetTitleFont  (42)
h.GetXaxis().SetTitleOffset(toX(p, 700))
h.GetXaxis().SetTitleSize  (toX(p, 30 ))
h.GetXaxis().SetLabelFont  (42)
h.GetXaxis().SetLabelOffset(toX(p, 5 ))
h.GetXaxis().SetLabelSize  (toX(p, 22))

h.GetYaxis().SetTitle      ("Entries")
h.GetYaxis().SetTitleFont  (42)
h.GetYaxis().SetTitleOffset(toX(p, 700))
h.GetYaxis().SetTitleSize  (toX(p, 30 ))
h.GetYaxis().SetLabelFont  (42)
h.GetYaxis().SetLabelOffset(toX(p, 5 ))
h.GetYaxis().SetLabelSize  (toX(p, 22))

h.Draw("hist")
c.SaveAs("blub.pdf")
c.SaveAs("blub.png")


