Belle II Software  release-05-02-19
DefineColourList Class Reference
Inheritance diagram for DefineColourList:
Collaboration diagram for DefineColourList:

Public Member Functions

def __init__ (self)
 
def __str__ (self)
 
def add (self)
 
def finish (self)
 
def save (self, filename, compile=False)
 

Public Attributes

 output
 Stores the outputted latex-code.
 

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 221 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 232 of file b2latex.py.

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

Member Function Documentation

◆ __str__()

def __str__ (   self)
inherited
Transform object to string, in this case, just returns .the generated latex-code

Definition at line 19 of file b2latex.py.

◆ add()

def add (   self)
inherited
Add latex-code to the output string.
This method is usually overriden in the subclasses

Definition at line 25 of file b2latex.py.

◆ finish()

def finish (   self)
inherited
Finishes the generation of latex-code.
E.g. adds end latex-commands
This method is usually overriden in the subclasses

Reimplemented in Itemize, and Graphics.

Definition at line 32 of file b2latex.py.

◆ save()

def save (   self,
  filename,
  compile = False 
)
inherited
Saves the latex-code into a file, adds preamble and end of document,
and compiles the code if requested.
    @param filename latex-code is stored in this file, should end on .tex
    @param compile compile the .tex file using pdflatex into a .pdf file

Definition at line 40 of file b2latex.py.


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