Skip to content

Add cividis colormap #1546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/base/inc/TColor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

24 changes: 22 additions & 2 deletions core/base/src/TColor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~

<table border=0>
Expand Down Expand Up @@ -898,6 +898,15 @@ Begin_Macro("width=300")
f2->Draw("surf2Z"); f2->SetTitle("kViridis");
}
End_Macro
</td><td>
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
</td></tr>
</table>

Expand Down Expand Up @@ -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 = 113 and colors=0, a Cividis palette is used.
/// ~~~
/// These palettes can also be accessed by names:
/// ~~~ {.cpp}
Expand All @@ -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}
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions tutorials/graphics/palettes.C
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,6 @@ void palettes() {
draw_palette(kCopper, "Copper");
draw_palette(kGistEarth, "Gist Earth");
draw_palette(kViridis, "Viridis");
draw_palette(kCividis, "Cividis");
}