From 31d4c5e2c35ce28dcf8586863392fe76719ff1b8 Mon Sep 17 00:00:00 2001 From: NichtJens Date: Mon, 22 Jan 2018 19:08:00 +0100 Subject: [PATCH 1/2] added cividis colormap to TColor and palettes tutorial --- core/base/inc/TColor.h | 2 +- core/base/src/TColor.cxx | 24 ++++++++++++++++++++++-- tutorials/graphics/palettes.C | 1 + 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/core/base/inc/TColor.h b/core/base/inc/TColor.h index 1ff84c0d3ba16..21d7c54b09656 100644 --- a/core/base/inc/TColor.h +++ b/core/base/inc/TColor.h @@ -123,6 +123,6 @@ class TColor : public TNamed { kStarryNight=102, kSunset=103, kTemperatureMap=104, kThermometer=105, kValentine=106, kVisibleSpectrum=107, kWaterMelon=108, kCool=109, kCopper=110, - kGistEarth=111, kViridis=112}; + kGistEarth=111, kViridis=112, kCividis=113}; #endif diff --git a/core/base/src/TColor.cxx b/core/base/src/TColor.cxx index 948073165c989..6242c5bd62de6 100644 --- a/core/base/src/TColor.cxx +++ b/core/base/src/TColor.cxx @@ -316,7 +316,7 @@ kSienna=99, kSolar=100, kSouthWest=101, kStarryNight=102, kSunset=103, kTemperatureMap=104, kThermometer=105, kValentine=106, kVisibleSpectrum=107, kWaterMelon=108, kCool=109, kCopper=110, -kGistEarth=111, kViridis=112 +kGistEarth=111, kViridis=112, kCividis=113 ~~~ @@ -898,6 +898,15 @@ Begin_Macro("width=300") f2->Draw("surf2Z"); f2->SetTitle("kViridis"); } End_Macro +
+Begin_Macro("width=300") +{ + c = new TCanvas("c","c",0,0,600,600); + TF2 *f2 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",0.999,3.002,0.999,3.002); + f2->SetContour(99); gStyle->SetPalette(kCividis); + f2->Draw("surf2Z"); f2->SetTitle("kCividis"); +} +End_Macro
@@ -2345,6 +2354,7 @@ Int_t TColor::CreateGradientColorTable(UInt_t Number, Double_t* Stops, /// if ncolors = 110 and colors=0, a Copper palette is used. /// if ncolors = 111 and colors=0, a Gist Earth palette is used. /// if ncolors = 112 and colors=0, a Viridis palette is used. +/// if ncolors = 112 and colors=0, a Cividis palette is used. /// ~~~ /// These palettes can also be accessed by names: /// ~~~ {.cpp} @@ -2368,7 +2378,7 @@ Int_t TColor::CreateGradientColorTable(UInt_t Number, Double_t* Stops, /// kStarryNight=102, kSunset=103, kTemperatureMap=104, /// kThermometer=105, kValentine=106, kVisibleSpectrum=107, /// kWaterMelon=108, kCool=109, kCopper=110, -/// kGistEarth=111 kViridis=112 +/// kGistEarth=111 kViridis=112, kCividis=113 /// ~~~ /// For example: /// ~~~ {.cpp} @@ -3067,6 +3077,16 @@ void TColor::SetPalette(Int_t ncolors, Int_t *colors, Float_t alpha) } break; + // Cividis + case 113: + { + Double_t red[9] = { 0./255., 5./255., 65./255., 97./255., 124./255., 156./255., 189./255., 224./255., 255./255.}; + Double_t green[9] = { 32./255., 54./255., 77./255., 100./255., 123./255., 148./255., 175./255., 203./255., 234./255.}; + Double_t blue[9] = { 77./255., 110./255., 107./255., 111./255., 120./255., 119./255., 111./255., 94./255., 70./255.}; + Idx = TColor::CreateGradientColorTable(18, stops, red, green, blue, 255, alpha); + } + break; + default: ::Error("SetPalette", "Unknown palette number %d", ncolors); return; diff --git a/tutorials/graphics/palettes.C b/tutorials/graphics/palettes.C index 5bc0d050b9d13..64057c08afd76 100644 --- a/tutorials/graphics/palettes.C +++ b/tutorials/graphics/palettes.C @@ -104,5 +104,6 @@ void palettes() { draw_palette(kCopper, "Copper"); draw_palette(kGistEarth, "Gist Earth"); draw_palette(kViridis, "Viridis"); + draw_palette(kCividis, "Cividis"); } From 2f46e3346cfcc1567bc4b543954cce01a4df2528 Mon Sep 17 00:00:00 2001 From: NichtJens Date: Mon, 22 Jan 2018 19:09:53 +0100 Subject: [PATCH 2/2] missed one number --- core/base/src/TColor.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/base/src/TColor.cxx b/core/base/src/TColor.cxx index 6242c5bd62de6..3ae646fcd7a8f 100644 --- a/core/base/src/TColor.cxx +++ b/core/base/src/TColor.cxx @@ -2354,7 +2354,7 @@ Int_t TColor::CreateGradientColorTable(UInt_t Number, Double_t* Stops, /// if ncolors = 110 and colors=0, a Copper palette is used. /// if ncolors = 111 and colors=0, a Gist Earth palette is used. /// if ncolors = 112 and colors=0, a Viridis palette is used. -/// if ncolors = 112 and colors=0, a Cividis palette is used. +/// if ncolors = 113 and colors=0, a Cividis palette is used. /// ~~~ /// These palettes can also be accessed by names: /// ~~~ {.cpp}