Logo ROOT  
Reference Guide
hist2image.C File Reference

Detailed Description

View in nbviewer Open in SWAN Create an image from a 2-D histogram and manipulate it.

#include <TAttImage.h>
void hist2image()
TCanvas *canv = new TCanvas("image", "xygaus + xygaus(5) + xylandau(10)");
// histogram as image (hist taken from draw2dopt.C)
TF2 *f2 = new TF2("f2","(xygaus + xygaus(5) + xylandau(10))",-4,4,-4,4);
Double_t params[] = {130,-1.4,1.8,1.5,1, 150,2,0.5,-2,0.5, 3600,-2,0.7,-3,0.3};
TH2D *h2 = new TH2D("h2","xygaus + xygaus(5) + xylandau(10)",100,-4,4,100,-4,4);
img->SetImage((const Double_t *)h2->GetArray(), h2->GetNbinsX() + 2,
double Double_t
Definition: RtypesCore.h:59
R__EXTERN TImagePalette * gHistImagePalette
Definition: TAttImage.h:109
const Double_t * GetArray() const
Definition: TArrayD.h:43
virtual void StartPaletteEditor()
Opens a GUI to edit the color palette.
Definition: TAttImage.cxx:780
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition: TAttPad.cxx:99
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition: TAttPad.cxx:109
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition: TAttPad.cxx:119
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition: TAttPad.cxx:129
The Canvas class.
Definition: TCanvas.h:23
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition: TCanvas.cxx:2446
virtual void SetParameters(const Double_t *params)
Definition: TF1.h:644
A 2-Dim function with parameters.
Definition: TF2.h:29
virtual Int_t GetNbinsY() const
Definition: TH1.h:297
virtual Int_t GetNbinsX() const
Definition: TH1.h:296
2-D histogram with a double per channel (see TH1 documentation)}
Definition: TH2.h:292
virtual void FillRandom(const char *fname, Int_t ntimes=5000, TRandom *rng=nullptr)
Fill histogram following distribution in function fname.
Definition: TH2.cxx:613
An abstract interface to image processing library.
Definition: TImage.h:29
virtual void SetImage(const Double_t *, UInt_t, UInt_t, TImagePalette *=0)
Definition: TImage.h:116
static TImage * Create()
Create an image.
Definition: TImage.cxx:35
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:197
Valeriy Onuchin

Definition in file hist2image.C.