Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TScatter2D.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Olivier Couet 23/09/2025
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_TScatter2D
13#define ROOT_TScatter2D
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TScatter2D //
19// //
20// A scatter plot able to draw five 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 "TGraph2D.h"
29
30class TH3F;
31
32class TScatter2D : public TNamed, public TAttLine, public TAttFill, public TAttMarker {
33
34protected:
35 Int_t fNpoints{-1}; ///< Number of points of arrays fX, fY and fZ
36 TGraph2D *fGraph{nullptr}; ///< Pointer to graph holding X, Y and Z positions
37 Double_t *fColor{nullptr}; ///< [fNpoints] array of colors
38 Double_t *fSize{nullptr}; ///< [fNpoints] array of marker sizes
39 Double_t fMaxMarkerSize{5.}; ///< Largest marker size used to paint the markers
40 Double_t fMinMarkerSize{1.}; ///< Smallest marker size used to paint the markers
41 Double_t fMargin{.1}; ///< Margin around the plot in %
42
43public:
44 TScatter2D();
46 TScatter2D(Int_t n, Double_t *x, Double_t *y, Double_t *z, const Double_t *col = nullptr, const Double_t *size = nullptr);
47 ~TScatter2D() override;
48
49 Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
50 void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
51 Double_t *GetColor() const {return fColor;} ///< Get the array of colors
52 Double_t *GetSize() const {return fSize;} ///< Get the array of marker sizes
53 Double_t GetMargin() const {return fMargin;} ///< Set the margin around the plot in %
54 Double_t GetMaxMarkerSize() const {return fMaxMarkerSize;} ///< Get the largest marker size used to paint the markers
55 Double_t GetMinMarkerSize() const {return fMinMarkerSize;} ///< Get the smallest marker size used to paint the markers
56 TGraph2D *GetGraph() const {return fGraph;} ///< Get the graph holding X, Y and Z positions
57 TH2D *GetHistogram() const; ///< Get the graph histogram used for drawing axis
58 TAxis *GetXaxis() const ;
59 TAxis *GetYaxis() const ;
60 TAxis *GetZaxis() const ;
61
62 void SetMaxMarkerSize(Double_t max) {fMaxMarkerSize = max;} ///< Set the largest marker size used to paint the markers
63 void SetMinMarkerSize(Double_t min) {fMinMarkerSize = min;} ///< Set the smallest marker size used to paint the markers
64 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(TScatter2D,1) //A 2D scatter plot
71};
72#endif
73
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
Option_t Option_t option
Fill Area Attributes class.
Definition TAttFill.h:20
Line Attributes class.
Definition TAttLine.h:20
Marker Attributes class.
Definition TAttMarker.h:20
Class to manage histogram axis.
Definition TAxis.h:32
Graphics object made of three arrays X, Y and Z with the same number of points each.
Definition TGraph2D.h:41
2-D histogram with a double per channel (see TH1 documentation)
Definition TH2.h:400
3-D histogram with a float per channel (see TH1 documentation)
Definition TH3.h:363
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
A TScatter2D is able to draw five variables scatter plot on a single plot.
Definition TScatter2D.h:32
void Paint(Option_t *chopt="") override
Paint this scatter plot with its current attributes.
TH2D * GetHistogram() const
Get the graph histogram used for drawing axis.
void SetMargin(Double_t)
Set the margin around the plot in %.
Double_t * GetColor() const
Get the array of colors.
Definition TScatter2D.h:51
Double_t fMargin
Margin around the plot in %.
Definition TScatter2D.h:41
TGraph2D * fGraph
Pointer to graph holding X, Y and Z positions.
Definition TScatter2D.h:36
Double_t fMaxMarkerSize
Largest marker size used to paint the markers.
Definition TScatter2D.h:39
Double_t GetMaxMarkerSize() const
Get the largest marker size used to paint the markers.
Definition TScatter2D.h:54
TGraph2D * GetGraph() const
Get the graph holding X, Y and Z positions.
Definition TScatter2D.h:56
void Print(Option_t *chopt="") const override
Print graph and errors values.
Double_t GetMinMarkerSize() const
Get the smallest marker size used to paint the markers.
Definition TScatter2D.h:55
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py,pz to a scatter plot.
TAxis * GetXaxis() const
Get the scatter's x axis.
~TScatter2D() override
TScatter2D default destructor.
Double_t * fSize
[fNpoints] array of marker sizes
Definition TScatter2D.h:38
Int_t fNpoints
Number of points of arrays fX, fY and fZ.
Definition TScatter2D.h:35
Double_t * GetSize() const
Get the array of marker sizes.
Definition TScatter2D.h:52
TAxis * GetYaxis() const
Get the scatter's y axis.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Double_t GetMargin() const
Set the margin around the plot in %.
Definition TScatter2D.h:53
TAxis * GetZaxis() const
Get the scatter's z axis.
void SetMaxMarkerSize(Double_t max)
Set the largest marker size used to paint the markers.
Definition TScatter2D.h:62
TScatter2D()
TScatter2D default constructor.
Double_t fMinMarkerSize
Smallest marker size used to paint the markers.
Definition TScatter2D.h:40
Double_t * fColor
[fNpoints] array of colors
Definition TScatter2D.h:37
void SetMinMarkerSize(Double_t min)
Set the smallest marker size used to paint the markers.
Definition TScatter2D.h:63
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16