2D histo Lego plot : suppressing the floor

Hello All,

I’m drawing TH2 histo in lego plots, with fine granularity (200x200 grid).

My data only has spikes here and there in the (x,y) plan, and as every line of every bin is drawn in black, it produces a floor almost uniformly black (see attachment). It makes it difficult to see the picture.

Is it possible to avoid drawing the empty bins ? so that we see only the towers ?
I tried TH1::SetMinimum(), but this just raises the floor to the minimum value…

Thanks for any help.


I haven’t tried it but maybe this thread contains the solution (use THStack):
root.cern.ch/phpBB2/viewtopic.ph … =zero+lego


Hi Jochen,

Thanks for the hint. But the graph I show is actualy done with a THStack…
So it does not help.


you get this picture because the LEGO option draws the outline of each box. Try the “SURF2” option (with a so fine binning surf or lego look almost the same) which does not draw the outlines.


Thanks for the suggestion. However, I’m using a THStack and when I try the “SURF” options, a crash occurs… whereas the ‘LEGO’ options work ok.

On the other hand, I could hack ROOT code. Maybe it is heretic but when adding these lines in TPainter3dAlgorithms at line 2447 (LegoCartesian() fct, root 5.17 )

double total_content=0;for (iv = 1; iv < nv; ++iv) total_content+=v[iv]; if(total_content==0) continue;

I get a nice result, both with plain TH2 and THStacks, see graphic.
Would it be possible to have this hack implemented has an option ?


ps: the crash when doing THStack::Draw(“SURF”) :

#1 0xb705b8c3 in waitpid () from /lib/i686/libc.so.6 #2 0xb700215b in __gxx_personality_v0 () from /lib/i686/libc.so.6 #3 0xb71191cd in system () from /lib/i686/libpthread.so.0 #4 0xb7a0d90d in TUnixSystem::Exec () from /home/delsart/SOFTWARE/root/lib/libCore.so #5 0xb7a12531 in TUnixSystem::StackTrace () from /home/delsart/SOFTWARE/root/lib/libCore.so #6 0xb7a11476 in TUnixSystem::DispatchSignals () from /home/delsart/SOFTWARE/root/lib/libCore.so #7 0xb7a115cd in SigHandler () from /home/delsart/SOFTWARE/root/lib/libCore.so #8 0xb7a0accd in sighandler () from /home/delsart/SOFTWARE/root/lib/libCore.so #9 <signal handler called> #10 0xb79e8078 in TClass::DynamicCast () from /home/delsart/SOFTWARE/root/lib/libCore.so #11 0xb65ba1a6 in THStack::Paint () from /home/delsart/SOFTWARE/root/lib/libHist.so #12 0xb61c00eb in TPad::PaintModified () from /home/delsart/SOFTWARE/root/lib/libGpad.so #13 0xb619f431 in TCanvas::Update () from /home/delsart/SOFTWARE/root/lib/libGpad.so ...

Oh sorry I missed that. It was not clear in your first post but you told it later on. Yes hack you did might be converted into an option. It need some thinking and a close look to make it properlly.

Ok, that would be great !
It could be as simple as a “hideminimum” option : the non-drawn bin would be the ones having their content<fMinimum.
Just ideas…


I have implemented what you requested. That is a new option called “0” when used with any lego option it allows to not draw the bins with 0 content. See the two attached pictures.
It works for single histograms or stacks.

Thank you very much for this fast reaction !