Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
_tscatter.pyzdoc
Go to the documentation of this file.
1\pythondoc TScatter
2
3The `TScatter` class in PyROOT can be used to create and visualize scatter plots dynamically. By integrating with NumPy, it allows efficient data management and customization.
4
5### Key Features:
61. **Efficient Data Handling**: Use NumPy arrays to manage and pass data points to the `TScatter` object.
72. **Visual Customization**: Adjust marker styles, colors, and titles to tailor the visualization.
83. **Canvas Layout Control**: Configure canvas margins to ensure that titles and axes are displayed without clipping.
94. **Exporting Plots**: Save scatter plots in various formats (e.g., `.png`, `.pdf`) for further use.
10
11### Example Usage:
12Below is a Python example demonstrating the use of `TScatter`:
13
14\code{.py}
15import ROOT
16import numpy as np
17
18# Create a TCanvas and configure margins
19canvas = ROOT.TCanvas("c1", "Scatter Plot Example", 800, 600)
20# Margins (left, right, bottom, top) to adjust the canvas layout and prevent clipping of titles or axis labels.
21canvas.SetMargin(0.1, 0.13, 0.1, 0.1)
22
23# Define the number of data points
24n = 175
25
26# Generate arrays for x, y coordinates and optional metadata
27x = 100*np.random.rand(n)
28y = 200*np.random.rand(n)
29c = 300*np.random.rand(n) # Optional: Color or other metadata
30s = 400*np.random.rand(n) # Optional: Size or other metadata
31
32# Create a TScatter object with the data
33scatter = ROOT.TScatter(n, x, y, c, s)
34
35# Customize the plot's appearance
36scatter.SetMarkerStyle(20) # Set marker style
37scatter.SetMarkerColor(4) # Set marker color
38scatter.SetTitle("Scatter plot title;X title;Y title;Z title") # Set plot and axis titles
39scatter.GetZaxis().SetTitleSize(0.04) # Modify the title size
40scatter.GetZaxis().SetTitleOffset(1.0) # Adjust the z-axis title offset
41
42# Draw the scatter plot
43scatter.Draw("AP") # "A" for Axis, "P" for Points
44
45# Save the scatter plot to a file
46canvas.SaveAs("scatter_plot_example.png")
47\endcode
48
49\endpythondoc
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
winID h TVirtualViewer3D TVirtualGLPainter char TVirtualGLPainter plot
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Option_t Option_t style
Color * colors
Definition X3DBuffer.c:21
A TScatter is able to draw four variables scatter plot on a single plot.
Definition TScatter.h:32
RooCmdArg Color(Color_t color)
RooCmdArg Layout(double xmin, double xmax=0.99, double ymin=0.95)
RooCmdArg Save(bool flag=true)
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
for(Int_t i=0;i< n;i++)
Definition legend1.C:18
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
TString as(SEXP s)
Definition RExports.h:86
const char * Size
Definition TXMLSetup.cxx:56