Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
gr006_scatter.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_graphs
3## \notebook
4## \preview Draw a scatter plot for 4 variables, mapped to: x, y, marker colour and marker size.
5##
6## TScatter is available since ROOT v.6.30. See the [TScatter documentation](https://root.cern/doc/master/classTScatter.html)
7##
8## \macro_image
9## \macro_code
10## \author Olivier Couet, Jamie Gooding
11
12import numpy as np
13import ROOT
14
15canvas = ROOT.TCanvas()
17ROOT.gStyle.SetPalette(ROOT.kBird, 0, 0.6) # define a transparent palette
18
19n = 175
20
21x = np.array([])
22y = np.array([])
23c = np.array([])
24s = np.array([])
25
26# Define four random data sets
27r = ROOT.TRandom()
28for i in range(n):
29 x = np.append(x, 100 * r.Rndm(i))
30 y = np.append(y, 200 * r.Rndm(i))
31 c = np.append(c, 300 * r.Rndm(i))
32 s = np.append(s, 400 * r.Rndm(i))
33
34scatter = ROOT.TScatter(n, x, y, c, s)
36scatter.SetTitle("Scatter plot titleX titleY titleZ title")
37scatter.GetXaxis().SetRangeUser(20.0, 90.0)
38scatter.GetYaxis().SetRangeUser(55.0, 90.0)
39scatter.GetZaxis().SetRangeUser(10.0, 200.0)
40scatter.Draw("A")
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.