Discussion:
[ROOT] color palette/grayscale
(too old to reply)
Olivier Couet
2004-03-02 09:41:33 UTC
Permalink
You can define more than 50 color. See the help of SetPalette in TStyle:

void TStyle::SetPalette(Int_t ncolors, Int_t *colors)
{
// The color palette is used by the histogram classes
// (see TH1::Draw options).
// For example TH1::Draw("col") draws a 2-D histogram with cells
// represented by a box filled with a color CI function of the cell
content.
// if the cell content is N, the color CI used will be the color number
// in colors[N],etc. If the maximum cell content is > ncolors, all
// cell contents are scaled to ncolors.
//
// if ncolors <= 0 a default palette (see below) of 50 colors is defined.
// the colors defined in this palette are OK for coloring pads, labels
//
// if ncolors == 1 && colors == 0, then
// a Pretty Palette with a Spectrum Violet->Red is created.
// It is recommended to use this Pretty palette when drawing legos,
// surfaces or contours.
//
// if ncolors > 50 and colors=0, the DeepSea palette is used.
// (see TStyle::CreateGradientColorTable for more details)
//
// if ncolors > 0 and colors = 0, the default palette is used
// with a maximum of ncolors.
//
// The default palette defines:
// index 0->9 : grey colors from light to dark grey
// index 10->19 : "brown" colors
// index 20->29 : "blueish" colors
// index 30->39 : "redish" colors
// index 40->49 : basic colors
//
// The color numbers specified in the palette can be viewed by selecting
// the item "colors" in the "VIEW" menu of the canvas toolbar.
// The color parameters can be changed via TColor::SetRGB.

This function is accessed via:

gStyle->SetPalette();

Cheers, O.Couet
I have question concerning the color palette and the number of colors
that one can defined in ROOT. I am interested in using ROOT to view a
2D image in grayscale (black and white) using the 2D histogram. I need
a grayscale of at least 8 bits. As far as I can understand it, ROOT
has a maximum of 50 colors. Is there a way to get more colors, in
particular in grayscale? If not, is this a feature that would be added
in the future?
Seng
--
Org: CERN - European Laboratory for Particle Physics.
Mail: 1211 Geneve 23 - Switzerland Mailbox: J25910
E-Mail: ***@cern.ch Phone: +41 22 7676522
WWW: http://cern.ch/Olivier.Couet/ Fax: +41 22 7677155
Olivier Couet
2004-03-02 18:35:36 UTC
Permalink
Hi Seng,

A gray scale palette is the easiest to create. It is enough to define
your colors in a loop like:

dcol = 1/ncol;
gray = 0;
for (int j = 0; j < ncol; j++) {
...... Define color with RGB equal to : gray, gray, gray .......
gray += dcol;
}

Olivier
Thanks Olivier. But how do I create a grayscale using
CreateGradientColorTable instead of the DeepSea palette. What do I set
for Red, Green, Blue, and Stops?
Seng
Post by Olivier Couet
You can define more than 50 color. See the help of SetPalette in
void TStyle::SetPalette(Int_t ncolors, Int_t *colors)
{
// The color palette is used by the histogram classes
// (see TH1::Draw options).
// For example TH1::Draw("col") draws a 2-D histogram with cells
// represented by a box filled with a color CI function of the cell
content.
// if the cell content is N, the color CI used will be the color number
// in colors[N],etc. If the maximum cell content is > ncolors, all
// cell contents are scaled to ncolors.
//
// if ncolors <= 0 a default palette (see below) of 50 colors is
defined.
// the colors defined in this palette are OK for coloring pads,
labels
//
// if ncolors == 1 && colors == 0, then
// a Pretty Palette with a Spectrum Violet->Red is created.
// It is recommended to use this Pretty palette when drawing legos,
// surfaces or contours.
//
// if ncolors > 50 and colors=0, the DeepSea palette is used.
// (see TStyle::CreateGradientColorTable for more details)
//
// if ncolors > 0 and colors = 0, the default palette is used
// with a maximum of ncolors.
//
// index 0->9 : grey colors from light to dark grey
// index 10->19 : "brown" colors
// index 20->29 : "blueish" colors
// index 30->39 : "redish" colors
// index 40->49 : basic colors
//
// The color numbers specified in the palette can be viewed by
selecting
// the item "colors" in the "VIEW" menu of the canvas toolbar.
// The color parameters can be changed via TColor::SetRGB.
gStyle->SetPalette();
Cheers, O.Couet
I have question concerning the color palette and the number of
colors
that one can defined in ROOT. I am interested in using ROOT to view a
2D image in grayscale (black and white) using the 2D histogram. I
need
a grayscale of at least 8 bits. As far as I can understand it, ROOT
has a maximum of 50 colors. Is there a way to get more colors, in
particular in grayscale? If not, is this a feature that would be added
in the future?
Seng
--
Org: CERN - European Laboratory for Particle Physics.
J25910
22 7676522
WWW: http://cern.ch/Olivier.Couet/ Fax: +41
22 7677155
--
Org: CERN - European Laboratory for Particle Physics.
Mail: 1211 Geneve 23 - Switzerland Mailbox: J25910
E-Mail: ***@cern.ch Phone: +41 22 7676522
WWW: http://cern.ch/Olivier.Couet/ Fax: +41 22 7677155
Woon-Seng Choong
2004-03-02 18:42:13 UTC
Permalink
Thanks Olivier. But how do I create a grayscale using
CreateGradientColorTable instead of the DeepSea palette. What do I set
for Red, Green, Blue, and Stops?

Seng
Post by Olivier Couet
You can define more than 50 color. See the help of SetPalette in
void TStyle::SetPalette(Int_t ncolors, Int_t *colors)
{
// The color palette is used by the histogram classes
// (see TH1::Draw options).
// For example TH1::Draw("col") draws a 2-D histogram with cells
// represented by a box filled with a color CI function of the cell
content.
// if the cell content is N, the color CI used will be the color number
// in colors[N],etc. If the maximum cell content is > ncolors, all
// cell contents are scaled to ncolors.
//
// if ncolors <= 0 a default palette (see below) of 50 colors is
defined.
// the colors defined in this palette are OK for coloring pads,
labels
//
// if ncolors == 1 && colors == 0, then
// a Pretty Palette with a Spectrum Violet->Red is created.
// It is recommended to use this Pretty palette when drawing legos,
// surfaces or contours.
//
// if ncolors > 50 and colors=0, the DeepSea palette is used.
// (see TStyle::CreateGradientColorTable for more details)
//
// if ncolors > 0 and colors = 0, the default palette is used
// with a maximum of ncolors.
//
// index 0->9 : grey colors from light to dark grey
// index 10->19 : "brown" colors
// index 20->29 : "blueish" colors
// index 30->39 : "redish" colors
// index 40->49 : basic colors
//
// The color numbers specified in the palette can be viewed by
selecting
// the item "colors" in the "VIEW" menu of the canvas toolbar.
// The color parameters can be changed via TColor::SetRGB.
gStyle->SetPalette();
Cheers, O.Couet
I have question concerning the color palette and the number of
colors
that one can defined in ROOT. I am interested in using ROOT to view a
2D image in grayscale (black and white) using the 2D histogram. I
need
a grayscale of at least 8 bits. As far as I can understand it, ROOT
has a maximum of 50 colors. Is there a way to get more colors, in
particular in grayscale? If not, is this a feature that would be added
in the future?
Seng
--
Org: CERN - European Laboratory for Particle Physics.
J25910
22 7676522
WWW: http://cern.ch/Olivier.Couet/ Fax: +41
22 7677155
Continue reading on narkive:
Loading...