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;
gStyle->SetLineStyleString(9,"400 20");
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 four basic line styles are:
1 = solid
2 = dash
3 = dot-dot
4 = dash-dot
Additional line styles can be defined using
TStyle::SetLineStyleString.
Example:
gStyle->SetLineStyleString(5,"20 12 4 12");
gStyle->SetLineStyleString(6,"20 12 4 12 4 12 4 12");
gStyle->SetLineStyleString(7,"20 20");
gStyle->SetLineStyleString(8,"20 12 4 12 4 12");
gStyle->SetLineStyleString(9,"80 20");
The following picture shows the first 10 line styles.
{
TCanvas *Ls = new TCanvas("Ls","test",500,200);
TText t;
t.SetTextAlign(32);
t.SetTextSize(0.08);
Int_t i=1;
gStyle->SetLineStyleString(9,"400 20");
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;
}