This tutorial demonstrates how the highlight mechanism can be used on an histogram.
A 2D histogram is booked an filled with a random gaussian distribution. Then an highlight method is connected to the histogram. Moving the mouse on the histogram will update the histogram title in real time according to the highlighted bin.
{
auto h2 =
dynamic_cast<TH2F *
>(obj);
if (!h2)
return;
if (!h2->IsHighlight()) {
h2->SetTitle("Disable highlight");
return;
}
if (info)
t.
Form(
"bin[%02d, %02d] (%5.2f, %5.2f) content %g", xhb, yhb, h2->GetXaxis()->GetBinCenter(xhb),
h2->GetYaxis()->GetBinCenter(yhb), h2->GetBinContent(xhb, yhb));
}
void hist043_Graphics_highlight()
{
c1->HighlightConnect(
"HighlightTitle(TVirtualPad*,TObject*,Int_t,Int_t)");
auto h2 =
new TH2F(
"h2",
"", 50, -5.0, 5.0, 50, -5.0, 5.0);
for (
Int_t i = 0; i < 10000; i++)
h2->Draw();
info =
new TText(0.0, -4.0,
"please move the mouse over the frame");
h2->SetHighlight();
}
int Int_t
Signed integer 4 bytes (int).
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
2-D histogram with a float per channel (see TH1 documentation)
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Mother of all ROOT objects.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
const char * Data() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
- Date
- March 2018
- Author
- Jan Musinsky
Definition in file hist043_Graphics_highlight.C.