Hi all!
I’ve come with this little example for a situation I’m dealing with
void leg(){
Double_t x[100], y[100];
Int_t n = 20;
for (Int_t i=0; i < n; i++) y[i] = - (x[i] = i);
TCanvas *c1 = new TCanvas("c1","",200,10,700,500);
gr = new TGraph(n,x,y);
gr->SetFillStyle(1001);
gr->SetFillColor(kBlue);
gr->SetMarkerStyle(2);
gr->SetMarkerColor(kRed);
gr->SetLineStyle(2);
gr->SetLineColor(kGreen);
gr->Draw("AP");
gPad->BuildLegend();
}
What I get is attached. The problem I see with that outcome is that the legend doesn’t honor what’s shown in the actual plot: in the plot only the marker is used, whereas in the legend all the Fill/Line/Marker attributes are used.
I’d like to have only the marker in the legend, with no line or fill atributes (if the fill attributes are set to hollow, a bounding box with fill color is shown nevertheless).
Am I doing something wrong, or have misunderstood something? A workaround may be to set the fill and line color according to the canvas’ fill color.
Thanks a lot for your help.