How to get label and axis titles for 2d histograms

Hi, I was wondering whether anyone had some advice for me. I’m making 1 and 2d histograms in root, and while I found in the ROOT documentation how to insert a histogram title and axis titles for the one-dimensional histograms, the same syntax isn’t working for the 2d histograms. ROOT gives no error when I give it the same commands, but it doesn’t change the titles. I am assuming that a different syntax is more appropriate to how ROOT handles 2d histograms, but I can’t seem to find anything relevant in the documentation. Here is the code I’ve been using to make the 1d histograms:

tree->Draw(“variable>>h()”);
h->SetTitle(“HistTitle”);
h->GetXaxis()->(“XaxisTitle”);
h->GetYaxis()->(“YaxisTitle”);

Again, this works fine for the 1d histograms, but when I draw 2d histograms in this format:

tree->Draw(“var1:var2>>h_12()”);

and follow with similar title commands, I don’t get any result on the histogram.

I would appreciate any advice!

One needs to issue a gPad()->Modified() but that’s true for both 1D and 2D histograms. I do not a different behavior for 1D and 2D. I tried with the SVN trunk on linux.

There’s one question that I would like to ask … which I’ve already asked on Sun Mar 13, 2011 19:57 here: [url]TPave::GetX1NDC() returns ridiculous values … is this described somewhere?

I suggest reading the Howtos about Graphics at
root.cern.ch/drupal/content/howtos#graf
and in particular: root.cern.ch/drupal/content/how-draw-objects

Rene

VIVE L’AMOUR!
well, I’ve read it. :-k
No Howto mentions “Modified”. #-o
The “How to Draw Objects ?” explicitly says … “This means that if the content of object changes, your picture will change.” … which makes explicit calls to “Modified” by the user obsolete. :mrgreen:
Do I get it right that old versions of ROOT sometimes required “Modified” while newer ones do not? :unamused:
Any clear rules when explicit call to “Update” is required (except obvious cases when one wants to perform an immediate screen’s update, of course)? 8-[
A typical situation:
TCanvas *c = new TCanvas();
something->Draw();
c->Update(); // usually NOT needed but in some cases required (e.g. otherwise “ChangeIt” will misbehave)
something->ChangeIt();
c->Modified(); // I changed “something” - so what? who cares?
c->Update(); // usually NOT needed (just “enforce” immediate screen’s update)
A pitiful case, am I not?
Pepe Le Pew.

You are partially right, but your mail shows that you did not read yet everything about graphics ::slight_smile:
see also: root.cern.ch/drupal/content/canvases-and-pads

I agree that TPad::Modified should also be mentioned at : root.cern.ch/drupal/content/how-draw-objects

Rene

Done.