# Custom palette in JSROOT

**URL:** <https://root-forum.cern.ch/t/custom-palette-in-jsroot/64090>\
**Category:** ROOT\
**Tags:** jsroot\
**Created:** [August 29, 2025, 8:18am UTC](https://root-forum.cern.ch/t/custom-palette-in-jsroot/64090 "2025-08-29T08:18:38Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [August 29, 2025, 1:10pm UTC](https://root-forum.cern.ch/t/custom-palette-in-jsroot/64090/5 "2025-08-29T13:10:26Z")

</div>

I don’t know if this works for JSROOT, but maybe you can give it a try and see (it might also explain why you get two bins with the same colour):

> [@How to set color with \`gStyle-\>SetPalette\` for first bin and last bin? may be bugs](https://root-forum.cern.ch/t/how-to-set-color-with-gstyle-setpalette-for-first-bin-and-last-bin-may-be-bugs/59457/6):
>
> Create a text file (e.g. “mycolours.txt”) with the RGB values (one colour per line, R G B separated by space) and use [TColor::CreateColorTableFromFile](https://root.cern/doc/master/classTColor.html#a8b075c0f885fe2e672b68d06ed966f6c) #include \<TStyle.h\> #include \<TFile.h\> #include \<TH2F.h\> void p3\_draw() { const int n = 6; Int\_t MyPalette[n]; Int\_t FI = TColor::CreateColorTableFromFile("mycolours.txt"); for (int i = 0; i \< n; i++) MyPalette[i] = FI + i; gStyle-\>SetPalette(n, MyPalette); gStyle-\>SetNumberContours(n); gStyle-\>SetOptStat(0); TH2F\* h2 = …

---

_[View the full topic](https://root-forum.cern.ch/t/custom-palette-in-jsroot/64090)._
