ra4_macros  bede988c286599a3a84b77a4d788ac0a971e89f9
set_palette.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import os, sys, re
3 import glob
4 import string
5 from array import array
6 from pprint import pprint
7 import ROOT
8 
9 
10 def set_palette(name="palette", ncontours=999):
11  """Set a color palette from a given RGB list
12  stops, red, green and blue should all be lists of the same length
13  see set_decent_colors for an example"""
14 
15  if name == "gray" or name == "grayscale":
16  stops = [0.00, 0.34, 0.61, 0.84, 1.00]
17  red = [1.00, 0.84, 0.61, 0.34, 0.00]
18  green = [1.00, 0.84, 0.61, 0.34, 0.00]
19  blue = [1.00, 0.84, 0.61, 0.34, 0.00]
20  elif name == "susy":
21  #NRGBs = 5
22  # NCont = 255
23  stops = [0.00, 0.34, 0.61, 0.84, 1.00]
24  red = [0.50, 0.50, 1.00, 1.00, 1.00]
25  green = [ 0.50, 1.00, 1.00, 0.60, 0.50]
26  blue = [1.00, 1.00, 0.50, 0.40, 0.50]
27 
28  else:
29  # default palette, looks cool
30  stops = [0.00, 0.34, 0.61, 0.84, 1.00]
31  red = [0.00, 0.00, 0.87, 1.00, 0.51]
32  green = [0.00, 0.81, 1.00, 0.20, 0.00]
33  blue = [0.51, 1.00, 0.12, 0.00, 0.00]
34 
35  s = array('d', stops)
36  r = array('d', red)
37  g = array('d', green)
38  b = array('d', blue)
39 
40  npoints = len(s)
41  ROOT.TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
42  ROOT.gStyle.SetNumberContours(ncontours)
def set_palette(name="palette", ncontours=999)
Definition: set_palette.py:10