Skip to content

TH2 not drawn if only TH2::AddBinContent is called (Entries=0). For TH1 it works. #14153

@ferdymercury

Description

@ferdymercury

Check duplicate issues.

  • Checked for duplicates

Description

Assume one only uses TH2::AddBinContent to fill a 2D histogram.
Then you draw it with COLZ.
Resulting canvas is empty.
In contrast, if you do the same with TH1::AddBinContent, it works without problems.

Reproducer

auto h2 = new TH2I("h2", "h2", 10, 0, 1, 2, 0, 2);
h2->AddBinContent(16,5);
h2->Draw("COLZ");

Nothing happens now, canvas is empty.

You are forced to:

h2->SetEntries(1)
gPad->Modified();
gPad->Update();

In contrast, with TH1, all works fine without calling SetEntries:

auto h = new TH1I("h", "h", 10, 0, 1);
h->AddBinContent(3,5)
h->Draw()

ROOT version

ROOT v6.30/02
Built for linuxx8664gcc on Nov 27 2023, 19:50:38
From tags/v6-30-02@
With c++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Binary directory: /opt/root/bin

Installation method

Binary

Operating system

Ubuntu 22.04

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions