Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TScatter.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Olivier Couet 18/05/2022
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TScatter
13#define ROOT_TScatter
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TScatter //
19// //
20// A scatter plot able to draw four variables on a single plot //
21// //
22//////////////////////////////////////////////////////////////////////////
23
24#include "TNamed.h"
25#include "TAttLine.h"
26#include "TAttFill.h"
27#include "TAttMarker.h"
28#include "TGraph.h"
29
30class TH2F;
31
32class TScatter : public TNamed, public TAttLine, public TAttFill, public TAttMarker {
33
34protected:
35 Int_t fMaxSize{-1}; ///<!Current dimension of arrays fX and fY
36 Int_t fNpoints{-1}; ///< Number of points <= fMaxSize
37 TH2F *fHistogram{nullptr}; ///< Pointer to histogram used for drawing axis
38 TGraph *fGraph{nullptr}; ///< Pointer to graph holding X and Y positions
39 Double_t *fColor{nullptr}; ///< [fNpoints] array of colors
40 Double_t *fSize{nullptr}; ///< [fNpoints] array of marker sizes
41 Double_t fMaxMarkerSize{5.}; ///< Largest marker size used to paint the markers
42 Double_t fMinMarkerSize{1.}; ///< Smallest marker size used to paint the markers
43 Double_t fMargin{.1}; ///< Margin around the plot in %
44
45public:
46 TScatter();
48 TScatter(Int_t n, const Double_t *x, const Double_t *y, const Double_t *col = nullptr, const Double_t *size = nullptr);
49 ~TScatter() override;
50
51 Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
52 void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
53 Double_t *GetColor() const {return fColor;} ///< Get the array of colors
54 Double_t *GetSize() const {return fSize;} ///< Get the array of marker sizes
55 Double_t GetMargin() const {return fMargin;} ///< Set the margin around the plot in %
56 Double_t GetMaxMarkerSize() const {return fMaxMarkerSize;} ///< Get the largest marker size used to paint the markers
57 Double_t GetMinMarkerSize() const {return fMinMarkerSize;} ///< Get the smallest marker size used to paint the markers
58 TGraph *GetGraph() const {return fGraph;} ///< Get the graph holding X and Y positions
59 TH2F *GetHistogram() const; ///< Get the graph histogram used for drawing axis
60
61 void SetMaxMarkerSize(Double_t max) {fMaxMarkerSize = max;} ///< Set the largest marker size used to paint the markers
62 void SetMinMarkerSize(Double_t min) {fMinMarkerSize = min;} ///< Set the smallest marker size used to paint the markers
63 void SetMargin(Double_t);
65 void Print(Option_t *chopt="") const override;
66 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
67 void Paint(Option_t *chopt="") override;
68
69
70 ClassDefOverride(TScatter,2) //A scatter plot
71};
72#endif
73
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
Fill Area Attributes class.
Definition TAttFill.h:19
Line Attributes class.
Definition TAttLine.h:18
Marker Attributes class.
Definition TAttMarker.h:19
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
A TScatter is able to draw four variables scatter plot on a single plot.
Definition TScatter.h:32
TGraph * GetGraph() const
Get the graph holding X and Y positions.
Definition TScatter.h:58
Int_t fMaxSize
!Current dimension of arrays fX and fY
Definition TScatter.h:35
Double_t GetMaxMarkerSize() const
Get the largest marker size used to paint the markers.
Definition TScatter.h:56
Double_t fMaxMarkerSize
Largest marker size used to paint the markers.
Definition TScatter.h:41
void Print(Option_t *chopt="") const override
Print graph and errors values.
Definition TScatter.cxx:196
void Paint(Option_t *chopt="") override
Paint this scatter plot with its current attributes.
Definition TScatter.cxx:186
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TScatter.cxx:149
TGraph * fGraph
Pointer to graph holding X and Y positions.
Definition TScatter.h:38
Double_t * GetSize() const
Get the array of marker sizes.
Definition TScatter.h:54
void SetHistogram(TH2F *h)
Definition TScatter.h:64
TScatter()
TScatter default constructor.
Definition TScatter.cxx:58
TH2F * GetHistogram() const
Get the graph histogram used for drawing axis.
Definition TScatter.cxx:159
Double_t * fColor
[fNpoints] array of colors
Definition TScatter.h:39
~TScatter() override
TScatter default destructor.
Definition TScatter.cxx:114
void SetMargin(Double_t)
Set the margin around the plot in %.
Definition TScatter.cxx:212
Double_t * GetColor() const
Get the array of colors.
Definition TScatter.h:53
Double_t GetMinMarkerSize() const
Get the smallest marker size used to paint the markers.
Definition TScatter.h:57
Double_t * fSize
[fNpoints] array of marker sizes
Definition TScatter.h:40
void SetMaxMarkerSize(Double_t max)
Set the largest marker size used to paint the markers.
Definition TScatter.h:61
Double_t fMargin
Margin around the plot in %.
Definition TScatter.h:43
void SetMinMarkerSize(Double_t min)
Set the smallest marker size used to paint the markers.
Definition TScatter.h:62
Double_t GetMargin() const
Set the margin around the plot in %.
Definition TScatter.h:55
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a scatter plot.
Definition TScatter.cxx:129
Double_t fMinMarkerSize
Smallest marker size used to paint the markers.
Definition TScatter.h:42
Int_t fNpoints
Number of points <= fMaxSize.
Definition TScatter.h:36
TH2F * fHistogram
Pointer to histogram used for drawing axis.
Definition TScatter.h:37
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TScatter.cxx:225
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16