Loading [MathJax]/extensions/tex2jax.js
Logo ROOT  
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
draw_rh2_colz.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_v7
3///
4/// This macro generates a small V7 TH2D, fills it with random values and
5/// draw it in a V7 canvas, using configured web browser
6///
7/// \macro_code
8///
9/// \date 2020-03-04
10/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
11/// \author Sergey Linev <s.linev@gsi.de>
12
13/*************************************************************************
14 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
15 * All rights reserved. *
16 * *
17 * For the licensing terms see $ROOTSYS/LICENSE. *
18 * For the list of contributors see $ROOTSYS/README/CREDITS. *
19 *************************************************************************/
20
22#include "ROOT/RCanvas.hxx"
23#include "ROOT/RFrameTitle.hxx"
25#include "ROOT/RHistStatBox.hxx"
26#include "ROOT/RFrame.hxx"
27#include "TRandom.h"
28
29// macro must be here while cling is not capable to load
30// library automatically for outlined function see ROOT-10336
31R__LOAD_LIBRARY(libROOTHistDraw)
32
33using namespace ROOT::Experimental;
34
35void draw_rh2_colz()
36{
37 // Create the histogram.
38 RAxisConfig xaxis("x", 20, 0., 10.);
39 RAxisConfig yaxis("y", 20, 0., 10.);
40 auto pHist = std::make_shared<RH2D>(xaxis, yaxis);
41
42 for (int n=0;n<10000;n++)
43 pHist->Fill({gRandom->Gaus(5.,2.), gRandom->Gaus(5.,2.)});
44
45 // Create a canvas to be displayed.
46 auto canvas = RCanvas::Create("Canvas Title");
47
48 auto frame = canvas->GetOrCreateFrame();
49
50 // should we made special style for frame with palette?
51 frame->Margins().SetRight(0.2_normal);
52
53 frame->SetGridX(true).SetGridY(false);
54
55 frame->AttrX().SetZoomMinMax(2.,8.);
56
57 frame->AttrY().SetZoomMinMax(2.,8.);
58
59 canvas->Draw<RFrameTitle>("2D histogram with color palette");
60
61 canvas->Draw<RPaletteDrawable>(RPalette::GetPalette(), true);
62
63 canvas->Draw(pHist);
64
65 auto stat = canvas->Draw<RHist2StatBox>(pHist, "hist2");
67
68 canvas->SetSize(1000, 700);
69 canvas->Show();
70
71 //canvas->Show("1000x700");
72
73 // canvas->SaveAs("rh2_colz.png");
74}
#define R__LOAD_LIBRARY(LIBRARY)
Definition: Rtypes.h:469
@ kRed
Definition: Rtypes.h:64
RAttrFill & SetColor(const RColor &color)
The fill color.
Definition: RAttrFill.hxx:37
Objects used to configure the different axis types.
Definition: RAxisConfig.hxx:35
A color palette draw near the frame.
const Int_t n
Definition: legend1.C:16