# THStack & TH2 with negative values

**URL:** <https://root-forum.cern.ch/t/thstack-th2-with-negative-values/16161>\
**Category:** ROOT\
**Created:** [May 29, 2013, 9:10pm UTC](https://root-forum.cern.ch/t/thstack-th2-with-negative-values/16161 "2013-05-29T21:10:39Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Zesp](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/z/b5ac83/32.png) [@Zesp](https://root-forum.cern.ch/u/Zesp)\
**Post date:** [May 29, 2013, 9:10pm UTC](https://root-forum.cern.ch/t/thstack-th2-with-negative-values/16161/1 "2013-05-29T21:10:39Z")

</div>

Hi there,

TH2 with negative values don’t get properly displayed in THStack (trunk commit c666419d502ab2854a1c28c4b91c6c24dc25e098).

[code]{  
gStyle-\>SetHistMinimumZero(kTRUE) ;  
gStyle-\>SetTitleFontSize(0.10) ;

TH2D \* histo = new TH2D (“histo”,“histo”,3,-3.,3.,3,-3.,3.) ;  
histo-\>SetBinContent(1,1, 1.) ;  
histo-\>SetBinContent(1,2, 3.) ;  
histo-\>SetBinContent(1,3, 4.) ;  
histo-\>SetBinContent(2,1,-6.) ;  
histo-\>SetBinContent(2,2, 0.) ;  
histo-\>SetBinContent(2,3, 9.) ;  
histo-\>SetBinContent(3,1,-8.) ;  
histo-\>SetBinContent(3,2, 2.) ;  
histo-\>SetBinContent(3,3,-5.) ;  
histo-\>SetMinimum(-10.) ;  
histo-\>SetMaximum( 10.) ;  
histo-\>SetStats(kFALSE) ;  
histo-\>SetFillColor(kRed) ;  
histo-\>SetLineColor(kBlack) ;

THStack \* hstack = new THStack (“hstack”,“hstack”) ;  
hstack-\>Add(histo) ;  
hstack-\>SetMinimum(-10.) ;  
hstack-\>SetMaximum( 10.) ;

TCanvas \* canvas = new TCanvas (“canvas”) ;  
canvas-\>Divide(2,3) ;  
canvas-\>cd(1) ; histo -\>Draw(“lego ,fb”) ;  
canvas-\>cd(3) ; histo -\>Draw(“lego1,fb”) ;  
canvas-\>cd(5) ; histo -\>Draw(“lego2,fb”) ;  
canvas-\>cd(2) ; hstack-\>Draw(“lego ,fb”) ;  
canvas-\>cd(4) ; hstack-\>Draw(“lego1,fb”) ;  
canvas-\>cd(6) ; hstack-\>Draw(“lego2,fb”) ;  
}[/code]  
I guess it has something to do with the way Hoption.Zero is handled in TPainter3dAlgorithms::LegoCartesian().  
Could you please fix this?

Cheers,  
Z

 ![](https://root-forum.cern.ch/uploads/default/original/2X/6/68f2e6348a2db0922715ef5f3aebe84c6cf78ab2.png)

---

_[View the full topic](https://root-forum.cern.ch/t/thstack-th2-with-negative-values/16161)._
