Plotting

RADICAL-Analytics does not provide plotting primitives. Instead, it offers helper methods that can be used with 3rd party plotting libraries.

Matplotlib

RADICAL-Analytics provides a style for Matplotlib. Loading it guarantees an uniform look&feel across plots. The style is located at styles/radical_mpl.txt.

Loading RADICAL-Analytics Style

import matplotlib.pyplot as plt
import radical.analytics as ra

plt.style.use(ra.get_mplstyle("radical_mpl")

Default Color Cycler of RADICAL-Analytics Style

01. #1a80b2 02. #ff801a 03. #339933 04. #cc3333 05. #9966b2
06. #804c4c 07. #e680cc 08. #b2b21a 09. #1ab2cc 10. #4c4c4c
11. #808080 12. #99b2b2 13. #b2cce6 14. #ffb280 15. #99e680
16. #ff9999 17. #ccb2cc 18. #cc9999 19. #ffb2cc 20. #e6e699
21. #99e6e6 22. #666666 23. #998080 24. #cccccc

Plotting for Latex Documents

In LaTeX documents, scaling images make the overall look&feel of a plot difficult to predict. Often, fonts are too small or too large, lines, bars, dots and axes too thin or too thick, and so on. Thus, plots should not be scaled in LaTeX—e.g., width=0.49\textwidth should not be used to scale a figure down of 50%—but, instead, plots should be created with the exact size of a column or a page. Column and page sizes depends on the .sty used for the LaTeX document and need to be inspected in order to know how to size a plot. Further, plots need to have their own style so that size, color, font face and overall features are consistent, readable and “pleasant” to look at.

Workflow with Matplotlib and Latex

The following assume the use of Matplotlib to create a plot that needs to be added to a LaTeX document for publication.

  1. Create a laTeX document using the following template:

    \documentclass{<your_style_eg_IEEEtran>}
    
    \newcommand{\recordvalue}[1]{%
      \typeout{%
        === Value of \detokenize{#1}: \the#1%
      }%
    }
    
    \begin{document}
      % gives the width of the current document in pts
      \recordvalue{\textwidth}
      \recordvalue{\columnwidth}
    \end{document}
    
  2. Compile your LaTeX document—e.g., pdlatex your_document—and note down the size of the text and of the column expressed in points (pts). An example output is shown below (shortened):

    $ pdflatex test.tex
    This is pdfTeX, [...]
    [...]
    === Value of \textwidth  : 252.0pt
    === Value of \columnwidth: 516.0pt
    (./test.aux) )
    No pages of output.
    Transcript written on test.log.
    
  3. Use ra.set_size() to compute the exact size of your plot. For a plot with a single figure that span the width of a IEEtran LaTeX column:

    fig, ax = plt.subplots(figsize=ra.get_plotsize(252))
    

    for plot with 1 row and 3 subplots that spans the whole width of a IEEtran LaTeX page:

    fig, axarr = plt.subplots(1, 3, figsize=(ra.set_size(516)))