Marker and Line Colors and Styles in Legends

Hi all,

I am writing a macro that makes several comparison plots between homogeneous histograms, and I have a problem with the colors of the histogram lines and markers in the legends.

The problem is the following. I want to plot the same histogram in two different canvases, changing its attributes (line and marker colors). Just to make an example, I want in the first canvas the histogram to be drawn with red dots, and in the second canvas the same histogram to be drawn with blue squares. I set the marker attributes of the histogram, then I use the DrawCopy() method, and it is drawn correctly in both canvases. However, when I add the histogram to the legends, the entry corresponding to the histogram in the first canvas is shown with blue squares, i.e. with the attributes that I set for the histogram in the second canvas. If I do not make the second plot (just commenting all the lines concerning the second canvas), the legend entry of the first canvas is shown with the correct histogram attributes.

Is there a way of overriding this problem without making a copy of the histogram?

You can use

TH1F *hclone = horg->DrawClone();
hclone->SetLineColor(…);

Thank you, it works even though it’s not properly what I was looking for, because I am working with many histograms and in this way I also get many clones.