ATLAS Offline Software
prettyPalette.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2 
3 # -*- coding: utf-8 -*-
4 from array import array
5 from ROOT import TColor, gStyle
6 
7 def set_palette(name="palette", ncontours=99):
8  """Set a color palette from a given RGB list
9  stops, red, green and blue should all be lists of the same length
10  see set_decent_colors for an example"""
11 
12  if name == "gray" or name == "grayscale":
13  stops = [0.00, 0.34, 0.61, 0.84, 1.00]
14  red = [1.00, 0.84, 0.61, 0.34, 0.00]
15  green = [1.00, 0.84, 0.61, 0.34, 0.00]
16  blue = [1.00, 0.84, 0.61, 0.34, 0.00]
17  # elif name == "whatever":
18  # (define more palettes)
19  else:
20  # default palette, looks cool
21  stops = [0.00, 0.34, 0.61, 0.84, 1.00]
22  red = [0.00, 0.00, 0.87, 1.00, 0.51]
23  green = [0.00, 0.81, 1.00, 0.20, 0.00]
24  blue = [0.51, 1.00, 0.12, 0.00, 0.00]
25 
26  s = array('d', stops)
27  r = array('d', red)
28  g = array('d', green)
29  b = array('d', blue)
30 
31  npoints = len(s)
32  TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours)
33  gStyle.SetNumberContours(ncontours)
34 
35 
prettyPalette.set_palette
def set_palette(name="palette", ncontours=99)
Definition: prettyPalette.py:7
array