ATLAS Offline Software
|
A 2-D histogram that can draw a proper scatter plot. More...
#include <ScatterH2.h>
Classes | |
struct | Pair |
One point. Avoid std::pair so that we don't have duplicate dicts. More... | |
Public Member Functions | |
ScatterH2 () | |
Default constructor. More... | |
ScatterH2 (const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup, Int_t nbinsy, Axis_t ylow, Axis_t yup) | |
Constructor. More... | |
ScatterH2 (const char *name, const char *title, Int_t nbinsx, const Double_t *xbins, Int_t nbinsy, Axis_t ylow, Axis_t yup) | |
Constructor. More... | |
ScatterH2 (const char *name, const char *title, const TArrayD &xbins, Int_t nbinsy, Axis_t ylow, Axis_t yup) | |
Constructor. More... | |
virtual void | Paint (Option_t *option="") |
Standard ROOT paint method. More... | |
virtual void | Reset (Option_t *option="") |
Standard ROOT reset method. More... | |
virtual Int_t | Fill (Axis_t x, Axis_t y, Stat_t w) |
Standard ROOT fill method. More... | |
virtual Int_t | Fill (Axis_t x, Axis_t y) |
Standard ROOT fill method. More... | |
bool | scatter () const |
Get the current value of the scatter flag. More... | |
bool | scatter (bool flag) |
Set the scatter flag. More... | |
int | shadestep () const |
Get the current value of shadestep. More... | |
int | shadestep (int shadestep) |
Set value of shadestep. More... | |
ScatterH2 * | rescale (const char *name, double xscale, double yscale) const |
Return a new plot with all data points multiplied by a constant. More... | |
Private Member Functions | |
virtual Int_t | Fill (Axis_t, const char *, Stat_t) |
virtual Int_t | Fill (const char *, Axis_t, Stat_t) |
virtual Int_t | Fill (const char *, const char *, Stat_t) |
Int_t | Fill (Axis_t) |
Int_t | Fill (const char *, Stat_t) |
ClassDef (RootUtils::ScatterH2, 1) | |
Private Attributes | |
bool | m_scatter |
The scatter flag. More... | |
int | m_shadestep |
shadestep option. More... | |
std::vector< Pair > | m_vals |
The collection of points that have been plotted. More... | |
A 2-D histogram that can draw a proper scatter plot.
This is a variation on TH2F
that can draw itself as a proper scatter plot — that is, each point really corresponds exactly to one Fill()
call. (The default behavior of TH2F
bins the histogram, and then dithers in random points when asked to draw a scatter plot.)
This is, in essence, a combination of TGraph2D
and TH2F
.
Use scatter()
to control whether we plot as a real scatter plot, or if we get the default root behavior.
Note that the implementation requires saving the values of all the points. Beware if you're trying to make plots with a really huge number of points.
If scatter plotting is on, it will be drawn by putting the default polymarker at each point. Note that once the plot starts getting dense, this can hide the structure of the distribution: if all points are set, then adding a new point makes no visible difference. To help with this, shading can also be used to show the distribution density. This is controlled by the parameter shadestep
.
If shadestep
is zero, no shading is done, and markers are drawn with the default color.
If shadestep
is greater than zero, then the color used for each pixel is ((N-1)*shadestep, 0, 0), (as (R,G,B)), where N is the number of data points plotted on the pixel.
If shadestep
is less then zero, the shading is done similarly, except that the scale factor is chosen to that the densest pixel will have a R channel of 255.
Definition at line 66 of file ScatterH2.h.
RootUtils::ScatterH2::ScatterH2 | ( | ) |
Default constructor.
Definition at line 34 of file ScatterH2.cxx.
RootUtils::ScatterH2::ScatterH2 | ( | const char * | name, |
const char * | title, | ||
Int_t | nbinsx, | ||
Axis_t | xlow, | ||
Axis_t | xup, | ||
Int_t | nbinsy, | ||
Axis_t | ylow, | ||
Axis_t | yup | ||
) |
Constructor.
name | Histogram name. |
title | Histogram title. |
nbinsx | Number of bins on x-axis. |
xlow | x-axis lower limit. |
xup | x-axis upper limit. |
nbinsy | Number of bins on y-axis. |
ylow | y-axis lower limit. |
yup | y-axis upper limit. |
Definition at line 52 of file ScatterH2.cxx.
RootUtils::ScatterH2::ScatterH2 | ( | const char * | name, |
const char * | title, | ||
Int_t | nbinsx, | ||
const Double_t * | xbins, | ||
Int_t | nbinsy, | ||
Axis_t | ylow, | ||
Axis_t | yup | ||
) |
Constructor.
name | Histogram name. |
title | Histogram title. |
nbinsx | Number of bins on x-axis. |
xbins | Array of bin boundaries. |
nbinsy | Number of bins on y-axis. |
ylow | y-axis lower limit. |
yup | y-axis upper limit. |
Definition at line 72 of file ScatterH2.cxx.
RootUtils::ScatterH2::ScatterH2 | ( | const char * | name, |
const char * | title, | ||
const TArrayD & | xbins, | ||
Int_t | nbinsy, | ||
Axis_t | ylow, | ||
Axis_t | yup | ||
) |
Constructor.
name | Histogram name. |
title | Histogram title. |
xbins | Array of bin boundaries. |
nbinsy | Number of bins on y-axis. |
ylow | y-axis lower limit. |
yup | y-axis upper limit. |
Definition at line 92 of file ScatterH2.cxx.
|
private |
|
virtual |
|
virtual |
Standard ROOT fill method.
x | x-coordinate. |
y | y-coordinate. |
w | Weight. |
This overrides the TH2
Fill method. The data point is saved in our list.
Definition at line 273 of file ScatterH2.cxx.
|
inlineprivate |
Definition at line 249 of file ScatterH2.h.
|
inlineprivatevirtual |
Definition at line 246 of file ScatterH2.h.
|
inlineprivatevirtual |
Definition at line 247 of file ScatterH2.h.
|
inlineprivatevirtual |
Definition at line 248 of file ScatterH2.h.
|
inlineprivate |
Definition at line 250 of file ScatterH2.h.
|
virtual |
Standard ROOT paint method.
option | Paint options. See TH2 . |
This overrides the TH2
Paint method. It suppresses the normal histogram plot if scatter mode is on.
Definition at line 110 of file ScatterH2.cxx.
Return a new plot with all data points multiplied by a constant.
name | Name for the new plot. |
xscale | x-axis scale factor. |
yscale | y-axis scale factor. |
Definition at line 355 of file ScatterH2.cxx.
|
virtual |
Standard ROOT reset method.
option | Reset options. See TH2 . |
This overrides the TH2
Reset method. We may need to clear the saved points, too.
Definition at line 252 of file ScatterH2.cxx.
bool RootUtils::ScatterH2::scatter | ( | ) | const |
Get the current value of the scatter flag.
If it's true, then this histogram will draw as a real scatter plot. Otherwise, the default root behavior is used.
Definition at line 298 of file ScatterH2.cxx.
bool RootUtils::ScatterH2::scatter | ( | bool | flag | ) |
Set the scatter flag.
flag | The new value of the scatter flag. |
If it's true, then this histogram will draw as a real scatter plot. Otherwise, the default root behavior is used.
Definition at line 312 of file ScatterH2.cxx.
int RootUtils::ScatterH2::shadestep | ( | ) | const |
Get the current value of shadestep.
If zero, no shading is done. If greater than zero, pixel brightness is increased by this much for each additional data point. If less than zero, pixel brightness is scaled so that pixels with the most data points have a brightness of 255.
Definition at line 329 of file ScatterH2.cxx.
int RootUtils::ScatterH2::shadestep | ( | int | shadestep | ) |
Set value of shadestep.
shadestep | The new value for shadestep. |
If zero, no shading is done. If greater than zero, pixel brightness is increased by this much for each additional data point. If less than zero, pixel brightness is scaled so that pixels with the most data points have a brightness of 255.
Definition at line 346 of file ScatterH2.cxx.
|
private |
|
private |
shadestep option.
If zero, no shading is done. If greater than zero, pixel brightness is increased by this much for each additional data point. If less than zero, pixel brightness is scaled so that pixels with the most data points have a brightness of 255.
Definition at line 228 of file ScatterH2.h.
|
private |
The collection of points that have been plotted.
Definition at line 240 of file ScatterH2.h.