Possible to "clone" just the plotting elements of a histo?

Hello,

Let’s say I have (because I do) multiple histograms with similar but not identical content, and I want to display them in a common way. I would like for all the histograms to have identical axes, axes labels, titles, title label fonts, font sizes, title widths, statistics styles, etc. etc. The only thing that differs between them is the actual bin contents, and the actual names and titles of the histograms.

Is there a way to copy these “plotting elements” of the histograms en masse without overwriting the actual bin contents?

Seems like it would be a useful capability to have…

Thanks,
-Phil D.

If you have a TH1 *h you can clone it with

TH1 *h2 = (TH1*)h->Clone("newname"); h2->Reset(); //this will reset the bin/error contents if you wish so
Rene

Rene wrote:

If you have a TH1 *h you can clone it with

Code: Select all
TH1 h2 = (TH1)h->Clone(“newname”);
h2->Reset(); //this will reset the bin/error contents if you wish so

Hi, Rene, unfortunately this doesn’t solve my problem. I’m saying I
have histograms saved in a root file with bin/error contents that must be
preserved, but I want them all to have the same plotting styles applied.
These are things that are not important necessarily when the histogram
is being filled in an analysis, only later when one wants to present plots
from the histograms - when they are also subject to changes not foreseen
at the time of filling. Note also that I could possibly use a global style, but
that would affect all histograms, not a specific set of histograms.

Is it possible?
Thanks,
-Phil D.
in question.

from the TH1 doc:

[quote] TH1::UseCurrentStyle() can be used to change all histogram graphics
attributes to correspond to the current selected style.
This function must be called for each histogram.
In case one reads and draws many histograms from a file, one can force
the histograms to inherit automatically the current graphics style
by calling before gROOT->ForceStyle().
[/quote]
You can create a TStyle with all the required settings, loop on all your histograms calling myhist->UseCurrentStyle and then revert to what was the current style.

Rene

Hi, Rene,
I just found the reference page for TH1::UseCurrentStyle at the same time, looks like just what I want - thanks!

Regards,
-Phil D.