Histograms and graphs with negative values

Hi Rooters

I have problems with negative values in 2D histograms as well with TGraph2D. I am using ROOT5 on a Redhat 8 Linux-intel box.
I would like to see negative values under the z=0 plane but couldn’t manage to do that.
For example, in 2D histograms, positive values should be drawn upwards and negative values downwards. This is the way Mathematica does it for instance.
Does anybody know how to do this in ROOT and even if it is possible?
I wouldn’t find any answer in the manual.

Thanks for your help

You did not tell what kind of representation you are using. Is it LEGO SURF BOX COL … ?
We have recently introduced the option BOX1 making the difference between + and - values. Can you give an example showing what you are doing ?

[quote=“couet”]You did not tell what kind of representation you are using. Is it LEGO SURF BOX COL … ?
We have recently introduced the option BOX1 making the difference between + and - values. Can you give an example showing what you are doing ?[/quote]

Sorry about the lack of picture last time. I have attached one that shows you what I would like to do (similar to Lego plot) with positive and negative values.

Thanks

Ok, that’s LEGO plots. ROOT lego plots do not allow such representations. But surface plots do. (option SURF suite)

Too bad! Having an histogram view is somehow "niceré to look than with the surface plot. Do you know if there is a plan to have the view I would like? It seems to be commonly used in matlab, mathematica and excel.

Thanks

We have plans to use openGL to render legos and surfaces. That kind of option can be included. I do not know how difficult/easy it is to do it with the current implementation of LEGOs. I should have a close look to evaluate.

The fix was easy. Now (in the CVS head) the LEGO optionS behave as you wish.

Hi Olivier

I checked the CVS head and tried the changes you made. That is exactly what I wanted, thanks.

Hi there,

This feature does not work with ROOT_5.16 anymore.
I reinstalled ROOT_5.14, it works !

TH2D *h =new TH2D ("h","h",2,0,2,2,0,2)
h->SetBinContent(1,1,5)                
h->SetBinContent(1,2,-2)               
h->SetBinContent(2,1,-7)               
h->SetBinContent(2,2,1)                
h->Draw("lego") 

Thanks for patching.
Zesp

Olivier will investigate this problem once he will be back

Rene

Try

gStyle->SetCanvasPreferGL(true);
TH2D *h =new TH2D ("h","h",2,0,2,2,0,2);
h->SetBinContent(1,1,5);
h->SetBinContent(1,2,-2);
h->SetBinContent(2,1,-7);
h->SetBinContent(2,2,1);
h->Draw("gllego");

In order to be compatible with the 1D histograms representation, the kind of plot you want is now obtained when you set the option:

gStyle->SetHistMinimumZero();

see:
root.cern.ch/root/Version516.news.html

Thanks :smiley:
Next time I’ll have a look to the release notes first :blush:
Z