デフォルトの色を変更したい(gROOT->GetColor->SetRGB)
1// 色番号3を緑に変更
2gROOT->GetColor(kGreen)->SetRGB(0.00, 0.70, 0.00);
SetRGB メソッドで、デフォルト色をカスタマイズできます。
ROOTのデフォルト配色は、蛍光が強すぎて見えにくい色があるので、変更することをオススメします。
1from ROOT import gROOT
2
3# 色番号3を緑に変更
4gROOT.GetColor(kGreen).SetRGB(0.00, 0.70, 0.00)
デフォルト配色一覧
|
番号 |
PAW互換値 |
デフォルト色 |
RGB値(10進) |
|---|---|---|---|---|
|
1 |
1 |
黒 |
(0, 0, 0) |
|
632 |
2 |
赤 |
(255, 0, 0) |
|
416 |
3 |
緑(蛍光) |
(0, 255, 0) |
|
600 |
4 |
青 |
(0, 0, 255) |
|
400 |
5 |
黄(蛍光) |
(255, 255, 0) |
|
616 |
6 |
マゼンタ |
(255, 0, 255) |
|
432 |
7 |
シアン(蛍光) |
(0, 255, 255) |
|
0 |
10 |
白 |
(255, 255, 255) |
|
920 |
- |
灰色 |
(128, 128, 128) |
|
800 |
- |
オレンジ |
(255, 127, 0) |
|
820 |
- |
黄緑 |
(255, 127, 127) |
|
840 |
- |
青緑 |
(0, 127, 127) |
|
860 |
- |
水色 |
(127, 127, 255) |
|
880 |
- |
紫 |
(127, 0, 127) |
|
900 |
- |
ピンク |
(255, 127, 255) |
色覚多様性したい
1// Use Okabe-Ito color palette for better visibility
2void setup_colors() {
3 const struct {
4 Color_t index;
5 float r, g, b;
6 } kOverrides[] = {
7 {kBlack, 0/255.f, 0/255.f, 0/255.f}, // Black
8 {kOrange, 230/255.f, 159/255.f, 0/255.f}, // Orange
9 {kCyan, 86/255.f, 180/255.f, 233/255.f}, // Sky Blue
10 {kGreen, 0/255.f, 158/255.f, 115/255.f}, // Bluish Green
11 {kYellow, 240/255.f, 228/255.f, 66/255.f}, // Yellow
12 {kBlue, 0/255.f, 114/255.f, 178/255.f}, // Blue
13 {kRed, 213/255.f, 94/255.f, 0/255.f}, // Vermillion
14 {kMagenta, 204/255.f, 121/255.f, 167/255.f}, // Reddish Purple
15 };
16
17 for (const auto& c : kOverrides) {
18 TColor* color = gROOT->GetColor(c.index);
19 if (color) color->SetRGB(c.r, c.g, c.b);
20 }
21}
Okabe-Itoカラーパレットを参考にして、 色覚多様性に配慮した配色に変更するサンプルです。
落ち着いた配色にしたい
1#include <TROOT.h>
2
3gROOT->GetColor(kGreen)->SetRGB(0.00, 0.70, 0.00); // Green
4gROOT->GetColor(kOrange)->SetRGB(1.00, 0.50, 0.00); // Orange
5gROOT->GetColor(kAzure)->SetRGB(0.15, 0.29, 0.56); // China Blue
6gROOT->GetColor(kTeal)->SetRGB(0.22, 0.37, 0.04); // Leaf Green
7gROOT->GetColor(kViolet)->SetRGB(0.50, 0.30, 0.70); // Purple
蛍光が強い色を落ち着いた色に変更します。 論文や報告書に向いています。
1from ROOT import gROOT
2
3gROOT.GetColor(kGreen).SetRGB(0.00, 0.70, 0.00) # Green
4gROOT.GetColor(kOrange).SetRGB(1.00, 0.50, 0.00) # Orange
5gROOT.GetColor(kAzure).SetRGB(0.15, 0.29, 0.56) # China Blue
6gROOT.GetColor(kTeal).SetRGB(0.22, 0.37, 0.04) # Leaf Green
7gROOT.GetColor(kViolet).SetRGB(0.50, 0.30, 0.70) # Purple
鮮やかな配色にしたい
1#include <TROOT.h>
2
3gROOT->GetColor(kRed)->SetRGB(0.95, 0.20, 0.20); // Coral Red
4gROOT->GetColor(kGreen)->SetRGB(0.20, 0.80, 0.20); // Emerald Green
5gROOT->GetColor(kBlue)->SetRGB(0.20, 0.40, 0.95); // Vibrant Blue
6gROOT->GetColor(kYellow)->SetRGB(0.95, 0.60, 0.10); // Gold
7gROOT->GetColor(kMagenta)->SetRGB(0.90, 0.20, 0.80); // Hot Pink
より鮮やかで視認性の高い配色です。 プレゼンテーションやスライドに向いています。
1from ROOT import gROOT
2
3gROOT.GetColor(kRed).SetRGB(0.95, 0.20, 0.20) # Coral Red
4gROOT.GetColor(kGreen).SetRGB(0.20, 0.80, 0.20) # Emerald Green
5gROOT.GetColor(kBlue).SetRGB(0.20, 0.40, 0.95) # Vibrant Blue
6gROOT.GetColor(kYellow).SetRGB(0.95, 0.60, 0.10) # Gold
7gROOT.GetColor(kMagenta).SetRGB(0.90, 0.20, 0.80) # Hot Pink
RGB値の変換方法
RGB値は0~255(10進数)で表されますが、ROOTでは0~1の範囲で指定します。
変換式
ROOTの値 = RGB値(10進数)/ 255
例
RGB(255, 0, 0) → SetRGB(1.0, 0.0, 0.0)
RGB(178, 34, 34) → SetRGB(0.70, 0.13, 0.13)