Not plotting zero bins in TH2 with negative entries

Resurrecting this old topic.

While option “1” is great, is there another option for TH2D with negative and positive values that will differentiate bins filled with value of “0” than those that are not filled ?

I would like to show bins filled actually with value of “0” and hide unfilled bins (leave them blank).

#include <TCanvas.h>
#include <TH2D.h>
#include <TRandom.h>

void drawTH2D() {

    TCanvas *c1 = new TCanvas("c1", "TH2D with COLZ1", 800, 600);

    TH2D *h2 = new TH2D("h2", "Random Integer Fill;X-axis;Y-axis", 10, 0, 10, 10, 0, 10);

    TRandom randGen;

    for (int ix = 1; ix <= h2->GetNbinsX(); ++ix) {
        for (int iy = 1; iy <= h2->GetNbinsY(); ++iy) {
            // Skip even Y-bin indices
            if (iy % 2 == 0) continue;

            // Random integer in range {-3, -2, -1, 0, 1, 2, 3}
            int value = randGen.Integer(7) - 3;

            h2->SetBinContent(ix, iy, value);
        }
    }

    h2->Draw("COLZ1");

    c1->Update();
}