New class TScatter
(30 May 2023)2D Scatter plots are a very popular way to represent scientific data. Many scientific plotting packages have this functionality. For many years ROOT itself as offered this kind of visualization via:
- The option
P
to draw TGraph: A marker is drawn at each point positions but all markers will have the same size and the same color. - The
COL
option ofTTree::Draw()
:tree.Draw("e1:e2:e3","","col")
produces a 2D scatter plot withe1
vse2
, and e3 is mapped on the current color palette. That’s a bit better as it allows to draw three variables on a 2D plot. But one needs to create aTTree
or aTNtuple
which is a bit heavy when the data are already stored in simple vectors.
Therefore there was a need for a new class able to produce, in a simple way, this famous multi-variables way to visualize data.
In order to full-fill these requirements a new class, TScatter
, has been
implemented. It is able to draw a four variables scatter plot on a single plot. The first two variables
are the x and y coordinates of the markers, the third one is mapped on the current color map, and
the fourth one on the marker size.
Note that it is recommended to use a transparent color map as markers will, most of the time, overlap.
The code to produce a scatter plot with the new class TScatter
is as simple as: