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)");
canv->SetRightMargin(0.2);
canv->SetLeftMargin(0.01);
canv->SetTopMargin(0.01);
canv->SetBottomMargin(0.01);
// 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};
f2->SetParameters(params);
TH2D *h2 = new TH2D("h2","xygaus + xygaus(5) + xylandau(10)",100,-4,4,100,-4,4);
h2->FillRandom("f2",40000);
img->SetImage((const Double_t *)h2->GetArray(), h2->GetNbinsX() + 2,
img->Draw();
}
Author
Valeriy Onuchin

Definition in file hist2image.C.

gHistImagePalette
R__EXTERN TImagePalette * gHistImagePalette
Definition: TAttImage.h:109
TAttPad::SetTopMargin
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition: TAttPad.cxx:129
TAttImage.h
TImage::Create
static TImage * Create()
Create an image.
Definition: TImage.cxx:35
TImage
Definition: TImage.h:29
TF1::SetParameters
virtual void SetParameters(const Double_t *params)
Definition: TF1.h:640
TArrayD::GetArray
const Double_t * GetArray() const
Definition: TArrayD.h:49
TAttPad::SetBottomMargin
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition: TAttPad.cxx:99
TH2::FillRandom
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
Definition: TH2.cxx:599
TAttImage::StartPaletteEditor
virtual void StartPaletteEditor()
Opens a GUI to edit the color palette.
Definition: TAttImage.cxx:780
TH2D
2-D histogram with a double per channel (see TH1 documentation)}
Definition: TH2.h:292
TCanvas::ToggleEventStatus
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition: TCanvas.cxx:2442
TF2
Definition: TF2.h:29
TAttPad::SetLeftMargin
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition: TAttPad.cxx:109
TObject::Draw
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:197
Double_t
double Double_t
Definition: RtypesCore.h:59
TAttPad::SetRightMargin
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition: TAttPad.cxx:119
TCanvas
Definition: TCanvas.h:23
TImage::SetImage
virtual void SetImage(const Double_t *, UInt_t, UInt_t, TImagePalette *=0)
Definition: TImage.h:116
TH1::GetNbinsY
virtual Int_t GetNbinsY() const
Definition: TH1.h:294
TH1::GetNbinsX
virtual Int_t GetNbinsX() const
Definition: TH1.h:293