Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
graph_edit_playback.C File Reference

Detailed Description

This macro plays a recorded ROOT session showing how to perform various interactive graphical editing operations.

The initial graphics setup was created using the following root commands:

TRecorder *t = new TRecorder();
t->Start("graphedit_playback.root");
TCanvas *c2 = new TCanvas("c2","c2",0,0,700,500);
TH2F* h2 = new TH2F("h2","Random 2D Gaussian",40,-4,4,40,-4,4);
h2->SetDirectory(0);
for (int i=0;i<50000;i++) h2->Fill(r.Gaus(),r.Gaus());
h2->Draw();
gPad->Update();
TCanvas *c1 = new TCanvas("c1","c1",0,0,700,500);
TH1F* h1 = new TH1F("h1","Random 1D Gaussian",100,-4,4);
h1->FillRandom("gaus",10000);
h1->Draw();
gPad->Update();
// Here the following "sketch" was done.
t->Stop();
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
R__EXTERN TStyle * gStyle
Definition TStyle.h:414
#define gPad
The Canvas class.
Definition TCanvas.h:23
1-D histogram with a float per channel (see TH1 documentation)}
Definition TH1.h:577
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
Definition TH1.cxx:8803
virtual void FillRandom(const char *fname, Int_t ntimes=5000, TRandom *rng=nullptr)
Fill histogram following distribution in function fname.
Definition TH1.cxx:3513
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3060
2-D histogram with a float per channel (see TH1 documentation)}
Definition TH2.h:257
Int_t Fill(Double_t) override
Invalid Fill method.
Definition TH2.cxx:347
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
Class provides direct recorder/replayer interface for a user.
Definition TRecorder.h:266
void Stop(Bool_t guiCommand=kFALSE)
Stopps recording events.
void Start(const char *filename, Option_t *option="RECREATE", Window_t *w=nullptr, Int_t winCount=0)
Starts recording events.
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
Definition TStyle.cxx:1781
return c1
Definition legend1.C:41
TH1F * h1
Definition legend1.C:5
return c2
Definition legend2.C:14

Note: The previous commands should be copy/pasted into a ROOT session, not executed as a macro.

The interactive editing shows

  • Object editing using object editors
  • Direct editing on the graphics canvas
  • Saving PS and bitmap files.
  • Saving as a .C file: C++ code corresponding to the modifications is saved.

The sketch of the recorded actions is

On the canvas c1

  • Open View/Editor
  • Select histogram
  • Change fill style
  • Change fill color
  • Move stat box
  • Change fill color
  • Move title
  • Change fill color using wheel color
  • Select Y axis
  • Change axis title
  • Select X axis
  • Change axis title
  • Select histogram
  • Go in binning
  • Change range
  • Move range
  • On the canvas menu set grid Y
  • On the canvas menu set grid X
  • On the canvas menu set log Y
  • Increase the range
  • Close View/Editor
  • Open the Tool Bar
  • Create a text "Comment"
  • Create an arrow
  • Change the arrow size
  • Close the Tool Bar
  • Save as PS file
  • Save as C file
  • Close c1

    On the canvas c2

  • Open View/Editor
  • Select histogram
  • Select COL
  • Select Palette
  • Move Stats
  • Select Overflows
  • Select histogram
  • Select 3D
  • Select SURF1
  • Rotate Surface
  • Go in binning
  • Change X range
  • Change Y range
  • Close View/Editor
  • Save as GIF file
  • Save as C file
  • Close c2
    Author
    Olivier Couet

Definition in file graph_edit_playback.C.