Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/base/inc/TVirtualPad.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class TVirtualPad : public TObject, public TAttLine, public TAttFill,
virtual void PaintPolyLineNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option="") = 0;
virtual void PaintPolyMarker(Int_t n, Float_t *x, Float_t *y, Option_t *option="") = 0;
virtual void PaintPolyMarker(Int_t n, Double_t *x, Double_t *y, Option_t *option="") = 0;
virtual void PaintMarker3D(Double_t x, Double_t y, Double_t z) = 0;
virtual void PaintModified() = 0;
virtual void PaintText(Double_t x, Double_t y, const char *text) = 0;
virtual void PaintText(Double_t x, Double_t y, const wchar_t *text) = 0;
Expand Down
1 change: 1 addition & 0 deletions graf2d/gpad/inc/TPad.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ friend class TWebCanvas;
void PaintPolyLineNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override;
void PaintPolyMarker(Int_t n, Float_t *x, Float_t *y, Option_t *option="") override;
void PaintPolyMarker(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override;
void PaintMarker3D(Double_t x, Double_t y, Double_t z) override;
void PaintModified() override;
void PaintText(Double_t x, Double_t y, const char *text) override;
void PaintText(Double_t x, Double_t y, const wchar_t *text) override;
Expand Down
25 changes: 24 additions & 1 deletion graf2d/gpad/src/TPad.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4491,8 +4491,8 @@ void TPad::PaintLine3D(Float_t *p1, Float_t *p2)

void TPad::PaintLine3D(Double_t *p1, Double_t *p2)
{
//take into account perspective view
if (!fView) return;

// convert from 3-D to 2-D pad coordinate system
Double_t xpad[6];
Double_t temp[3];
Expand All @@ -4504,6 +4504,29 @@ void TPad::PaintLine3D(Double_t *p1, Double_t *p2)
PaintLine(xpad[0],xpad[1],xpad[3],xpad[4]);
}

////////////////////////////////////////////////////////////////////////////////
/// Paint 3-D marker in the CurrentPad.

void TPad::PaintMarker3D(Double_t x, Double_t y, Double_t z)
{
if (!fView) return;

Double_t rmin[3], rmax[3];
fView->GetRange(rmin, rmax);

// convert from 3-D to 2-D pad coordinate system
Double_t xpad[3];
Double_t temp[3];
temp[0] = x;
temp[1] = y;
temp[2] = z;
if (x<rmin[0] || x>rmax[0]) return;
if (y<rmin[1] || y>rmax[1]) return;
if (z<rmin[2] || z>rmax[2]) return;
fView->WCtoNDC(temp, &xpad[0]);
PaintPolyMarker(1, &xpad[0], &xpad[1]);
}

////////////////////////////////////////////////////////////////////////////////
/// Paint polyline in CurrentPad World coordinates.

Expand Down
2 changes: 2 additions & 0 deletions hist/hist/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(Hist
TGraphSmooth.h
TGraphTime.h
TScatter.h
TScatter2D.h
TH1C.h
TH1D.h
TH1F.h
Expand Down Expand Up @@ -136,6 +137,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(Hist
TGraphSmooth.cxx
TGraphTime.cxx
TScatter.cxx
TScatter2D.cxx
TH1.cxx
TH1K.cxx
TH1Merger.cxx
Expand Down
1 change: 1 addition & 0 deletions hist/hist/inc/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#pragma link C++ class TGraphMultiErrors+;
#pragma link C++ class TGraphBentErrors+;
#pragma link C++ class TScatter+;
#pragma link C++ class TScatter2D+;
#pragma link C++ class TGraph2D-;
#pragma link C++ class TGraph2DErrors-;
#pragma link C++ class TGraph2DAsymmErrors-;
Expand Down
73 changes: 73 additions & 0 deletions hist/hist/inc/TScatter2D.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// @(#)root/hist:$Id$
// Author: Olivier Couet 23/09/2025

/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/

#ifndef ROOT_TScatter2D
#define ROOT_TScatter2D


//////////////////////////////////////////////////////////////////////////
// //
// TScatter2D //
// //
// A scatter plot able to draw five variables on a single plot //
// //
//////////////////////////////////////////////////////////////////////////

#include "TNamed.h"
#include "TAttLine.h"
#include "TAttFill.h"
#include "TAttMarker.h"
#include "TGraph2D.h"

class TH3F;

class TScatter2D : public TNamed, public TAttLine, public TAttFill, public TAttMarker {

protected:
Int_t fNpoints{-1}; ///< Number of points of arrays fX, fY and fZ
TGraph2D *fGraph{nullptr}; ///< Pointer to graph holding X, Y and Z positions
Double_t *fColor{nullptr}; ///< [fNpoints] array of colors
Double_t *fSize{nullptr}; ///< [fNpoints] array of marker sizes
Double_t fMaxMarkerSize{5.}; ///< Largest marker size used to paint the markers
Double_t fMinMarkerSize{1.}; ///< Smallest marker size used to paint the markers
Double_t fMargin{.1}; ///< Margin around the plot in %

public:
TScatter2D();
TScatter2D(Int_t n);
TScatter2D(Int_t n, Double_t *x, Double_t *y, Double_t *z, const Double_t *col = nullptr, const Double_t *size = nullptr);
~TScatter2D() override;

Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
Double_t *GetColor() const {return fColor;} ///< Get the array of colors
Double_t *GetSize() const {return fSize;} ///< Get the array of marker sizes
Double_t GetMargin() const {return fMargin;} ///< Set the margin around the plot in %
Double_t GetMaxMarkerSize() const {return fMaxMarkerSize;} ///< Get the largest marker size used to paint the markers
Double_t GetMinMarkerSize() const {return fMinMarkerSize;} ///< Get the smallest marker size used to paint the markers
TGraph2D *GetGraph() const {return fGraph;} ///< Get the graph holding X, Y and Z positions
TH2D *GetHistogram() const; ///< Get the graph histogram used for drawing axis
TAxis *GetXaxis() const ;
TAxis *GetYaxis() const ;
TAxis *GetZaxis() const ;

void SetMaxMarkerSize(Double_t max) {fMaxMarkerSize = max;} ///< Set the largest marker size used to paint the markers
void SetMinMarkerSize(Double_t min) {fMinMarkerSize = min;} ///< Set the smallest marker size used to paint the markers
void SetMargin(Double_t);
void Print(Option_t *chopt="") const override;
void SavePrimitive(std::ostream &out, Option_t *option = "") override;
void Paint(Option_t *chopt="") override;


ClassDefOverride(TScatter2D,1) //A 2D scatter plot
};
#endif

2 changes: 2 additions & 0 deletions hist/hist/inc/TVirtualGraphPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

class TGraph;
class TScatter;
class TScatter2D;
class TF1;

class TVirtualGraphPainter : public TObject {
Expand All @@ -42,6 +43,7 @@ class TVirtualGraphPainter : public TObject {
virtual void PaintGraph(TGraph *theGraph, Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt) = 0;
virtual void PaintGrapHist(TGraph *theGraph, Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt) = 0;
virtual void PaintScatter(TScatter *theScatter, Option_t *option) = 0;
virtual void PaintScatter2D(TScatter2D *theScatter, Option_t *option) = 0;
virtual void PaintStats(TGraph *theGraph, TF1 *fit) = 0;
virtual void SetHighlight(TGraph *theGraph) = 0;

Expand Down
11 changes: 1 addition & 10 deletions hist/hist/src/TScatter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@


#include "TROOT.h"
#include "TBuffer.h"
#include "TScatter.h"
#include "TStyle.h"
#include "TMath.h"
#include "TVirtualPad.h"
#include "TH2.h"
#include "TVirtualGraphPainter.h"
#include "strtok.h"

#include <iostream>
#include <fstream>
#include <cstring>
#include <string>

#include <iostream>


////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading
Loading