Re: manipulating histogramms

Valery Fine (fine@mail.cern.ch)
Fri, 8 Aug 1997 14:30:16 +0100


On 8 Aug 97 at 9:34, Elemer Nagy wrote:

> >
> > On 7 Aug 97 at 18:02, Elemer Nagy wrote:
> >
> > >
> > >
> > > I have transformed a hbook histogram into a root one. I can
> > > manipulate it fairly well with the mouse. However I am unable to
> > > make disappear the original title, which remains always in the left
> > > upper corner. I can move it e.g. to the middle of the plot, but when
> > > I use the "delete" bar it disappears from the middle but will
> > > reappear in the left upper corner. Have you got an idea? Thanks.
> >
> > Did you see any menu bar on the top of our "Canvas" widget ?
> >
> > It contains "Option" -> "Histogram Title" position to hide
> > histogram title.
> >
>
> There is "Options" but no -> "Histogram Title" ! So what to do?

Are you sure ? Could you tell me what did you see under "Option"? At
least my version does contain it.

>
> > Did you evaluate our Web home page ?
> >
> > Please try first to find out whether our Web site contains a
> > response for your question. Look up out Digest first, try to apply
> > "Search engine"
> >
> > Try: http://root.cern.ch/root/Search.phtml
> >
> > Select: "Title" in "RootDigest"
> > Select "Search"
> > Enjoy !
> >
>
> I cannot enjoy this search because usually the mails do not
> correspond
> to my question. I have seen that somebody has asked the same
> question but I couldn't find the answer in the Digest!
>
> In PAW it was very simple: you had to type
>
> hi/copy oldid newid ' '
>

No it is not very simple. It does create a SECOND histogram with
another title but doesn't change the title of the original one.

Probably I misuderstood your question, sorry.

> and this eliminated the title. Isn't there such a similar thing in
> ROOT?

I am very sorry but I would like to pass you again to our
documentation. ROOT is supplied as a free software "AS IS". Even
for the commercial product with a "free" support it is assumed user
reads and understands the documentation.

What about your case. To change the title of ANY TNamed object
(most of the ROOT object are derived from this class) one needs
to issue

<Object_Name>.SetTitle("Title");

But I'd like to mention that it was not your question. Even
your object, namely the histogram, has an empty title the title BOX
will be still drawn but empty.

What about our documentation sure they are not perfect yet and must
be improved. Anyway it does contain:

http://root.cern.ch/root/Howto.html

the one may click

http://root.cern.ch/root/HowtoHistogram.html

and find at the bottom

" ...
Other histogram facilities

A long list of histogram service functions is provided. See class
TH1 for a complete list.

... "

>
> Also I see when clicking with the right button of the mouse
> inside
> the pave many options, e.g. addline addtext delete etc. the problem
> is that addline and addtext works but delete doesn't. Are you sure
> isn't there a bug?

Not it is not a bug but feature. Since the delete function
doesn't delete the title of your histogram but just deletes the
"TPaveText" object from the TPad. Since you don't create this object
yourself it was done by automatic and this object will be regenerated
every time the Histogram object is painted on the screen unless the
user toggles this selecting "Histogram Title" option (or he changes
this via TStyle *gStyle object see:

http://root.cern.ch/cgi-bin/print_hit_bold.pl/root/roottalk/0562.html?gStyle#first_hit

>
> > >
> > > I observe also that when manipulating histograms with the
> > > mouse,
> > > these manipulations (e.g. change of axis label fonts, adding axis
> > > titles, coloring the histogramms, etc) are not registrated in the
> > > root_hist file. Is there an option which would keep track of these
> > > manipulations in form of commands in order to reuse them later
> > > easily in a macro?
> >
> > Just the same advice:
> >
> > Try: http://root.cern.ch/root/Search.phtml
> >
> > Select: "Save" in "RootDigest"
> > Select "Search"
> > Enjoy !
>
> As I told you this is not a very good idea! There are thousands
> of
> irrelevant mails I have to look through, why cannot you answer
> straight?

It seems to me I did it, since I did tell you

use "Save as .C"

that's very straight answer. And I use my own free time to reply you.

Then I tried to explain you how to find the answers faster, namely
reading the original documentation.

>
>
> >
> > Or select from "canvas" menu bar "File" -> "Save as .C" to generate
> > a macro file with your current canvas set.
> >
>
> This I have tried but when I have executed the macro c1.C it
> didn't do anything else than plotted a beautifully empty canvas
> although there were a lot of c++ instructions stored in the file
> c1.C

That's what you wanted. It re-created/restored the positions of the
all ROOT objects the USER created and Drawn into that TCanvas..

It requires some explanation. On the screen one can watch TWO
kind of the objects.

1. User's object. These are the objects the user does create himself
with his code/macro/mouse manipulations

2. Attribute objects. The objects of this type are created by ROOT
alone to present some object attributes. For example the
title of the histogram is not a separate object but a parameter
of the histogram. To draw that title ROOT itself creates the
"TPaveText" object using the histogram title to initialized it.

The objects of the second type are not saved with "Save as .C"
function since they are recreated from the "parent" object anyway. So
even we saved it it will make no sense (like your attempting to
delete the histogram title with deleting the TPaveText object). I.e. the
appearance of that objects are defined by the parent object
attributes/properties and all changes affect it temporary and
are kept as long as the object is displayed on the screen.

So that macro will contain a constructors of the "User's" objects

The user objects are any objects created with user's macro
DIRECTLY (like histograms, ntuple, TPad's etc)
and those created via "Edit->Editor".
(see http://root.cern.ch/root/HowtoEdit.html)

The attribute "system created" objects like the histogram axis and
the title will be NOT saved but they can be managed indirectly by change
the histogram parameters. The common behaviour of these
"attribute" objects are defined with TStyle *gStyle global object and
can be affected by change that object as well.

(see again:
http://root.cern.ch/cgi-bin/print_hit_bold.pl/root/roottalk/0562.html?gStyle#first_hit

One can create the USER's object from the attribute one. For that
one should apply the copy constructor and then Draw() a new "copy"
object to the same TCanvas. This way "Save as" function will save
that object as well. This object will have no "parent" object
anymore and will be not changed "by automatic". So it will be the user's
responsibility" to change the appearance of that. For instance the
"user's" TPaveText object created from the "Histogram title"
TPaveText one will contain one and the same text even the title of
the "parent" histogram will be changed.

>
> > Hope this helps.
>
> So sorry it didn't help. Do you have other ideas?
>

I am very regret on this. But may be this message will help you.

> NB. Do you know when will Rene return from holidays?

I think next week.

With my best regards,
Valery
=================================================================
Dr. Valery Fine Telex : 911621 dubna su
-----------
LCTA/Joint Inst.for NuclearRes Phone : +7 09621 6 40 80
141980 Dubna, Moscow region Fax : +7 09621 6 51 45
Russia mailto:fine@main1.jinr.dubna.su

Dr. Valeri Faine
------------ Phone: +41 22 767 6468
CERN FAX : +41 22 767 7910
CH-1211 Geneva, 23 mailto:fine@mail.cern.ch
Switzerland http://nicewww.cern.ch/~fine