This tutorial demonstrates how the highlight mechanism can be used on an histogram.
A 1D histogram is created. Then an highlight method is connected to the histogram. Moving the mouse on the histogram will open a new canvas showing in real time a zoom around the highlighted bin.
void hlHisto4()
{
auto Canvas1 =
new TCanvas(
"Canvas1",
"", 0, 0, 600, 400);
auto f1 =
new TF1(
"f1",
"x*gaus(0) + [3]*abs(sin(x)/x)", -50.0, 50.0);
auto h1 =
new TH1F(
"h1",
"Test random numbers", 200, -50.0, 50.0);
Canvas1->SetGrid();
Canvas1->Update();
Canvas1->HighlightConnect("HighlightZoom(TVirtualPad*,TObject*,Int_t,Int_t)");
}
{
auto Canvas2 = (
TCanvas *)
gROOT->GetListOfCanvases()->FindObject(
"Canvas2");
if (Canvas2) delete Canvas2;
if (hz) { delete hz; hz = 0; }
return;
}
if (!Canvas2) {
Canvas2 =
new TCanvas(
"Canvas2",
"Canvas2", 605, 0, 400, 400);
Canvas2->SetGrid();
}
if (!hz) {
hz = (
TH1 *)
h->Clone(
"hz");
Canvas2->Update();
}
Canvas2->Modified();
Canvas2->Update();
}
R__EXTERN TStyle * gStyle
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis from bin first to last.
virtual void SetParameters(const Double_t *params)
1-D histogram with a float per channel (see TH1 documentation)}
virtual void SetTitle(const char *title)
See GetStatOverflows for more information.
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
virtual Int_t GetNbinsX() const
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual void SetHighlight(Bool_t set=kTRUE)
Set highlight (enable/disable) mode for the histogram by default highlight mode is disable.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
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.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void SetGridColor(Color_t color=0)
Base class for several text objects.
TVirtualPad is an abstract base class for the Pad and Canvas classes.