Line Attributes class
This class is used (in general by secondary inheritance)
by many other classes (graphics, histograms). It holds all the line attributes.
Line attributes
Line attributes are:
Line Color
The line color is a color index (integer) pointing in the ROOT
color table.
The line color of any class inheriting from
TAttLine can
be changed using the method
SetLineColor and retrieved using the
method
GetLineColor.
The following table shows the first 50 default colors.
{
TCanvas *c = new TCanvas("c","Line colors",0,0,500,200);
c.DrawColorTable();
return c;
}
Line Width
The line width is expressed in pixel units.
The line width of any class inheriting from
TAttLine can
be changed using the method
SetLineWidth and retrieved using the
method
GetLineWidth.
The following picture shows the line widths from 1 to 10 pixels.
{
TCanvas *Lw = new TCanvas("Lw","test",500,200);
TText t;
t.SetTextAlign(32);
t.SetTextSize(0.08);
Int_t i=1;
for (float s=0.1; s<1.0 ; s+=0.092) {
TLine *lh = new TLine(0.15,s,.85,s);
lh->SetLineWidth(i);
t.DrawText(0.1,s,Form("%d",i++));
lh->Draw();
}
return Lw;
}
Line Style
Line styles are identified via integer numbers. The line style of any class
inheriting from
TAttLine can be changed using the method
SetLineStyle and retrieved using the method
GetLineStyle.
The first 10 line styles are predefined as shown on the following picture:
{
TCanvas *Ls = new TCanvas("Ls","test",500,200);
TText t;
t.SetTextAlign(32);
t.SetTextSize(0.08);
Int_t i=1;
for (float s=0.1; s<1.0 ; s+=0.092) {
TLine *lh = new TLine(0.15,s,.85,s);
lh->SetLineStyle(i);
t.DrawText(0.1,s,Form("%d",i++));
lh->Draw();
}
return Ls;
}
Additional line styles can be defined using
TStyle::SetLineStyleString.
For example the line style number 11 can be defined as follow:
gStyle->SetLineStyleString(11,"400 200");
Existing line styles (1 to 10) can be redefined using the same method.