Line colors : TLegend

hi,
I am having troubles with line colors in TLegend

{
//=========Macro generated from canvas: c1/c1
//=========  (Mon Oct 29 17:12:06 2012) by ROOT version5.20/00
   TCanvas *c1 = new TCanvas("c1", "c1",15,49,1659,980);
   gStyle->SetOptStat(0);
   c1->Range(-3.989362,-624.3893,31.01064,5585.935);
   c1->SetBorderSize(2);
   c1->SetFrameFillColor(0);
   
   TH1 *h1 = new TH1F("h1","BPTO 10 lpmm",28,-0.5,27.5);
   h1->SetBinContent(1,173.9885);
   h1->SetBinContent(2,180.1765);
   h1->SetBinContent(3,197.2176);
   h1->SetBinContent(4,2734.916);
   h1->SetBinContent(5,4274.363);
   h1->SetBinContent(6,1432.13);
   h1->SetBinContent(7,4474.487);
   h1->SetBinContent(8,1044.466);
   h1->SetBinContent(9,4684.089);
   h1->SetBinContent(10,740.572);
   h1->SetBinContent(11,4731.675);
   h1->SetBinContent(12,989.3372);
   h1->SetBinContent(13,4568.641);
   h1->SetBinContent(14,1152.229);
   h1->SetBinContent(15,4513.103);
   h1->SetBinContent(16,1658.505);
   h1->SetBinContent(17,4078.862);
   h1->SetBinContent(18,2026.632);
   h1->SetBinContent(19,3902.687);
   h1->SetBinContent(20,2341.337);
   h1->SetBinContent(21,3539.951);
   h1->SetBinContent(22,2697.766);
   h1->SetBinContent(23,3195.683);
   h1->SetBinContent(24,3799.469);
   h1->SetBinContent(25,269.1548);
   h1->SetBinContent(26,186.4336);
   h1->SetBinContent(27,162.8826);
   h1->SetBinContent(28,153.8586);
   h1->SetEntries(28);
   h1->SetDirectory(0);
   h1->SetLineColor(2);
   h1->SetLineWidth(6);
   h1->GetXaxis()->SetTitle("Position x 50 microns");
   h1->GetYaxis()->SetTitle("Intensity (au)");
   h1->GetYaxis()->SetTitleOffset(1.2);
   h1->Draw("hist c");
   
   TH1 *h1 = new TH1F("h1","BPTO 10 lpm",28,-0.5,27.5);
   h1->SetBinContent(1,178.2032);
   h1->SetBinContent(2,356.08);
   h1->SetBinContent(3,1054.532);
   h1->SetBinContent(4,1560.094);
   h1->SetBinContent(5,2192.944);
   h1->SetBinContent(6,2637.799);
   h1->SetBinContent(7,3139.445);
   h1->SetBinContent(8,3236.706);
   h1->SetBinContent(9,3250.74);
   h1->SetBinContent(10,3213.206);
   h1->SetBinContent(11,3232.136);
   h1->SetBinContent(12,3161.638);
   h1->SetBinContent(13,3153.152);
   h1->SetBinContent(14,3151.847);
   h1->SetBinContent(15,3155.437);
   h1->SetBinContent(16,3171.103);
   h1->SetBinContent(17,3193.623);
   h1->SetBinContent(18,3125.737);
   h1->SetBinContent(19,3147.278);
   h1->SetBinContent(20,3138.139);
   h1->SetBinContent(21,3308.509);
   h1->SetBinContent(22,3077.759);
   h1->SetBinContent(23,2709.276);
   h1->SetBinContent(24,2168.466);
   h1->SetBinContent(25,1623.738);
   h1->SetBinContent(26,967.3889);
   h1->SetBinContent(27,347.9206);
   h1->SetBinContent(28,165.4744);
   h1->SetEntries(28);
   h1->SetStats(0);
   h1->SetLineWidth(6);
   h1->Draw("hist c same");
   
   TLegend *leg = new TLegend(0.7556231,0.7881081,0.9963526,0.9772973,NULL,"brNDC");
   leg->SetTextFont(62);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(19);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("NULL","Legend","h");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("h1","Horizontal Scan","l");
   entry->SetLineColor(2);
   entry->SetLineStyle(1);
   entry->SetLineWidth(6);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry=leg->AddEntry("h1","Vertical Scan","l");
   entry->SetLineColor(1);  //this outputs RED, why????
   entry->SetLineStyle(1);
   entry->SetLineWidth(6);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   leg->Draw();
   
   TPaveText *pt = new TPaveText(0.01,0.9418108,0.1910942,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(2);
   pt->SetFillColor(19);
   TText *text = pt->AddText("BPTO 10 lpmm");
   pt->Draw();
   c1->Modified();
   c1->cd();
   c1->SetSelected(c1);
}

This outputs a red line in the Legend
f.

A brutal fix … either this … [code]{
TCanvas *c1 = new TCanvas(“c1”, “c1”,15,49,1659,980);
gStyle->SetOptStat(0);
c1->Range(-3.989362,-624.3893,31.01064,5585.935);
c1->SetBorderSize(2);
c1->SetFrameFillColor(0);

TH1 *h1 = new TH1F(“h1_lpmm”,“BPTO 10 lpmm”,28,-0.5,27.5);
h1->SetBinContent(1,173.9885);
h1->SetBinContent(2,180.1765);
h1->SetBinContent(3,197.2176);
h1->SetBinContent(4,2734.916);
h1->SetBinContent(5,4274.363);
h1->SetBinContent(6,1432.13);
h1->SetBinContent(7,4474.487);
h1->SetBinContent(8,1044.466);
h1->SetBinContent(9,4684.089);
h1->SetBinContent(10,740.572);
h1->SetBinContent(11,4731.675);
h1->SetBinContent(12,989.3372);
h1->SetBinContent(13,4568.641);
h1->SetBinContent(14,1152.229);
h1->SetBinContent(15,4513.103);
h1->SetBinContent(16,1658.505);
h1->SetBinContent(17,4078.862);
h1->SetBinContent(18,2026.632);
h1->SetBinContent(19,3902.687);
h1->SetBinContent(20,2341.337);
h1->SetBinContent(21,3539.951);
h1->SetBinContent(22,2697.766);
h1->SetBinContent(23,3195.683);
h1->SetBinContent(24,3799.469);
h1->SetBinContent(25,269.1548);
h1->SetBinContent(26,186.4336);
h1->SetBinContent(27,162.8826);
h1->SetBinContent(28,153.8586);
h1->SetEntries(28);
h1->SetDirectory(0);
h1->SetLineColor(2);
h1->SetLineWidth(6);
h1->GetXaxis()->SetTitle(“Position x 50 microns”);
h1->GetYaxis()->SetTitle(“Intensity (au)”);
h1->GetYaxis()->SetTitleOffset(1.2);
h1->Draw(“hist c”);

TH1 *h1 = new TH1F(“h1_lpm”,“BPTO 10 lpm”,28,-0.5,27.5);
h1->SetBinContent(1,178.2032);
h1->SetBinContent(2,356.08);
h1->SetBinContent(3,1054.532);
h1->SetBinContent(4,1560.094);
h1->SetBinContent(5,2192.944);
h1->SetBinContent(6,2637.799);
h1->SetBinContent(7,3139.445);
h1->SetBinContent(8,3236.706);
h1->SetBinContent(9,3250.74);
h1->SetBinContent(10,3213.206);
h1->SetBinContent(11,3232.136);
h1->SetBinContent(12,3161.638);
h1->SetBinContent(13,3153.152);
h1->SetBinContent(14,3151.847);
h1->SetBinContent(15,3155.437);
h1->SetBinContent(16,3171.103);
h1->SetBinContent(17,3193.623);
h1->SetBinContent(18,3125.737);
h1->SetBinContent(19,3147.278);
h1->SetBinContent(20,3138.139);
h1->SetBinContent(21,3308.509);
h1->SetBinContent(22,3077.759);
h1->SetBinContent(23,2709.276);
h1->SetBinContent(24,2168.466);
h1->SetBinContent(25,1623.738);
h1->SetBinContent(26,967.3889);
h1->SetBinContent(27,347.9206);
h1->SetBinContent(28,165.4744);
h1->SetEntries(28);
h1->SetStats(0);
h1->SetLineWidth(6);
h1->Draw(“hist c same”);

TLegend *leg = new TLegend(0.7556231,0.7881081,0.9963526,0.9772973,NULL,“brNDC”);
leg->SetTextFont(62);
leg->SetLineColor(1);
leg->SetLineStyle(1);
leg->SetLineWidth(1);
leg->SetFillColor(19);
leg->SetFillStyle(1001);
TLegendEntry *entry=leg->AddEntry(“NULL”,“Legend”,“h”);
//entry->SetLineColor(1);
//entry->SetLineStyle(1);
//entry->SetLineWidth(1);
//entry->SetMarkerColor(1);
//entry->SetMarkerStyle(21);
//entry->SetMarkerSize(1);
//entry->SetTextFont(62);
entry=leg->AddEntry(“h1_lpmm”,“Horizontal Scan”,“l”);
//entry->SetLineColor(2);
//entry->SetLineStyle(1);
//entry->SetLineWidth(6);
//entry->SetMarkerColor(1);
//entry->SetMarkerStyle(21);
//entry->SetMarkerSize(1);
entry=leg->AddEntry(“h1_lpm”,“Vertical Scan”,“l”);
//entry->SetLineColor(1); //this outputs RED, why???
//entry->SetLineStyle(1);
//entry->SetLineWidth(6);
//entry->SetMarkerColor(1);
//entry->SetMarkerStyle(21);
//entry->SetMarkerSize(1);
leg->Draw();

TPaveText *pt = new TPaveText(0.01,0.9418108,0.1910942,0.995,“blNDC”);
pt->SetName(“title”);
pt->SetBorderSize(2);
pt->SetFillColor(19);
TText *text = pt->AddText(“BPTO 10 lpmm”);
pt->Draw();
c1->Modified();
c1->cd();
c1->SetSelected(c1);
}[/code] … or that … [code]{
TCanvas *c1 = new TCanvas(“c1”, “c1”,15,49,1659,980);
gStyle->SetOptStat(0);
c1->Range(-3.989362,-624.3893,31.01064,5585.935);
c1->SetBorderSize(2);
c1->SetFrameFillColor(0);

TH1 *h1 = new TH1F(“h1”,“BPTO 10 lpmm”,28,-0.5,27.5);
TH1 *h1_lpmm = h1;
h1->SetBinContent(1,173.9885);
h1->SetBinContent(2,180.1765);
h1->SetBinContent(3,197.2176);
h1->SetBinContent(4,2734.916);
h1->SetBinContent(5,4274.363);
h1->SetBinContent(6,1432.13);
h1->SetBinContent(7,4474.487);
h1->SetBinContent(8,1044.466);
h1->SetBinContent(9,4684.089);
h1->SetBinContent(10,740.572);
h1->SetBinContent(11,4731.675);
h1->SetBinContent(12,989.3372);
h1->SetBinContent(13,4568.641);
h1->SetBinContent(14,1152.229);
h1->SetBinContent(15,4513.103);
h1->SetBinContent(16,1658.505);
h1->SetBinContent(17,4078.862);
h1->SetBinContent(18,2026.632);
h1->SetBinContent(19,3902.687);
h1->SetBinContent(20,2341.337);
h1->SetBinContent(21,3539.951);
h1->SetBinContent(22,2697.766);
h1->SetBinContent(23,3195.683);
h1->SetBinContent(24,3799.469);
h1->SetBinContent(25,269.1548);
h1->SetBinContent(26,186.4336);
h1->SetBinContent(27,162.8826);
h1->SetBinContent(28,153.8586);
h1->SetEntries(28);
h1->SetDirectory(0);
h1->SetLineColor(2);
h1->SetLineWidth(6);
h1->GetXaxis()->SetTitle(“Position x 50 microns”);
h1->GetYaxis()->SetTitle(“Intensity (au)”);
h1->GetYaxis()->SetTitleOffset(1.2);
h1->Draw(“hist c”);

TH1 *h1 = new TH1F(“h1”,“BPTO 10 lpm”,28,-0.5,27.5);
TH1 *h1_lpm = h1;
h1->SetBinContent(1,178.2032);
h1->SetBinContent(2,356.08);
h1->SetBinContent(3,1054.532);
h1->SetBinContent(4,1560.094);
h1->SetBinContent(5,2192.944);
h1->SetBinContent(6,2637.799);
h1->SetBinContent(7,3139.445);
h1->SetBinContent(8,3236.706);
h1->SetBinContent(9,3250.74);
h1->SetBinContent(10,3213.206);
h1->SetBinContent(11,3232.136);
h1->SetBinContent(12,3161.638);
h1->SetBinContent(13,3153.152);
h1->SetBinContent(14,3151.847);
h1->SetBinContent(15,3155.437);
h1->SetBinContent(16,3171.103);
h1->SetBinContent(17,3193.623);
h1->SetBinContent(18,3125.737);
h1->SetBinContent(19,3147.278);
h1->SetBinContent(20,3138.139);
h1->SetBinContent(21,3308.509);
h1->SetBinContent(22,3077.759);
h1->SetBinContent(23,2709.276);
h1->SetBinContent(24,2168.466);
h1->SetBinContent(25,1623.738);
h1->SetBinContent(26,967.3889);
h1->SetBinContent(27,347.9206);
h1->SetBinContent(28,165.4744);
h1->SetEntries(28);
h1->SetStats(0);
h1->SetLineWidth(6);
h1->Draw(“hist c same”);

TLegend *leg = new TLegend(0.7556231,0.7881081,0.9963526,0.9772973,NULL,“brNDC”);
leg->SetTextFont(62);
leg->SetLineColor(1);
leg->SetLineStyle(1);
leg->SetLineWidth(1);
leg->SetFillColor(19);
leg->SetFillStyle(1001);
TLegendEntry *entry=leg->AddEntry(“NULL”,“Legend”,“h”);
//entry->SetLineColor(1);
//entry->SetLineStyle(1);
//entry->SetLineWidth(1);
//entry->SetMarkerColor(1);
//entry->SetMarkerStyle(21);
//entry->SetMarkerSize(1);
//entry->SetTextFont(62);
entry=leg->AddEntry(h1_lpmm,“Horizontal Scan”,“l”);
//entry->SetLineColor(2);
//entry->SetLineStyle(1);
//entry->SetLineWidth(6);
//entry->SetMarkerColor(1);
//entry->SetMarkerStyle(21);
//entry->SetMarkerSize(1);
entry=leg->AddEntry(h1_lpm,“Vertical Scan”,“l”);
//entry->SetLineColor(1); //this outputs RED, why???
//entry->SetLineStyle(1);
//entry->SetLineWidth(6);
//entry->SetMarkerColor(1);
//entry->SetMarkerStyle(21);
//entry->SetMarkerSize(1);
leg->Draw();

TPaveText *pt = new TPaveText(0.01,0.9418108,0.1910942,0.995,“blNDC”);
pt->SetName(“title”);
pt->SetBorderSize(2);
pt->SetFillColor(19);
TText *text = pt->AddText(“BPTO 10 lpmm”);
pt->Draw();
c1->Modified();
c1->cd();
c1->SetSelected(c1);
}[/code]

The graphics attributes are taken form the object you pout un the legend.
You added twice h1 … so you get twice the h1 attributes.
See the TLegend help: root.cern.ch/root/html/TLegend.html