Belle II Software development
DefineColourList Class Reference
Inheritance diagram for DefineColourList:
LatexObject

Public Member Functions

def __init__ (self)
 

Static Public Attributes

list colours = ["red", "green", "blue", "orange", "cyan", "purple"]
 6 default colours used for the bargraph
 

Detailed Description

Defines the colourlist latex-command, which draws a bargraph with relative
fractions indicated by colours using tikz.
After including this object in you latex code the command \\bargraph is available.
You should include only one of these objects in your latex code.

Definition at line 228 of file b2latex.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)
Calls super-class init, adds definition of colourlist to latex code.

Reimplemented from LatexObject.

Definition at line 239 of file b2latex.py.

239 def __init__(self):
240 """
241 Calls super-class init, adds definition of colourlist to latex code.
242 """
243 super().__init__()
244 self.output += r"\def\colourlist{{" + ', '.join(f'"{c}"' for c in self.colours) + r"}}" + '\n'
245 self.output += r"""
246 \tikzset{nodeStyle/.style={text height=\heightof{A},text depth=\depthof{g}, inner sep = 0pt, node distance = -0.15mm}}
247 \newcount\colourindex \colourindex=-1
248 \newcommand{\plotbar}[1]{
249 \begin{tikzpicture}[start chain=going right, nodes = {font=\sffamily}]
250 \global\colourindex=-1
251 \foreach \percent/\name in {
252 #1
253 } {
254 \ifx\percent\empty\else % If \percent is empty, do nothing
255 \global\advance\colourindex by 1
256 \ifnum"""
257 self.output += str(len(self.colours) - 1)
258 self.output += r"""5<\colourindex %back to first colour if we run out
259 \global\colourindex=0
260 \fi
261 \pgfmathparse{\colourlist[\the\colourindex]} % Get color from cycle list
262 \edef\color{\pgfmathresult} % and store as \color
263 \node[nodeStyle, draw, on chain, fill={\color!40}, minimum width=\percent*1.0, minimum height=12] {\name};
264 \fi
265 };
266 \end{tikzpicture}
267 }
268 """
269
270

Member Data Documentation

◆ colours

list colours = ["red", "green", "blue", "orange", "cyan", "purple"]
static

6 default colours used for the bargraph

Definition at line 237 of file b2latex.py.


The documentation for this class was generated from the following file: