Default Fill Style

Hi, I keep needing to SetFillStyle(0) when I draw TGraphs with coloured lines, when I want a sensible legend. Is there a way to set a default FillStyle for TGraphs (or for everything)? I tried looking in .rootrc and didn’t find such an option. Even a global command to give at the beginning of a script/program would be nice.

Jean-Francois

can you post a small macro showing how you do the legend ?

I use PyROOT, but I posted this in ROOT Support because I figured it was probably not PyROOT-specific.

Here is my PyROOT code:

import ROOT,os,numpy
ROOT.gROOT.Macro( os.path.expanduser( '~/Macros/rootlogon.C' ) )
c1 = ROOT.TCanvas()
graphs = {}
ngraphs, npoints = 5,100
mg = ROOT.TMultiGraph()
xs = numpy.linspace(0,10,npoints) # Equally spaced points
for N in range(ngraphs):
    ys = xs**N # Just computes x**N for each x
    g = ROOT.TGraph(npoints, xs, ys)
    g.SetTitle('{0}'.format(N))
    g.SetLineColor(N+2)
    g.SetFillStyle(0) # Commenting this line makes an ugly Legend.
    graphs[N] = g
    mg.Add(g)
mg.Draw('AL')
c1.BuildLegend(0.1,0.7,0.3,0.9)
ROOT.gPad.Update()
raw_input('Press enter to finish.') # Pauses execution

You can copy the code, and %paste it into an IPython window, I don’t know if pasting into a plain python interpreter will work, but you can definitely paste it into a .py file and run it with python. If the SetFillStyle line is commented out, the legend elements have a black background, which clashes with the rest of the colour scheme.

Jean-François

You are using “BuildLegend”. This method creates automatically a legend for all the attributes for all the object in a pad (see help). As, in your case, you do not need the fill attributes, you should create the TLegend yourself and not use this automatic way.