4

Many investent fund factsheets have a simple risk diagram as below, along with the annotation:

enter image description here

How would one recreate this in TeX? I though of using a table but perhaps some sort of tikz picture might be better. Being very new to TeX I am unsure of where to begin.

8

One possibility, using a TikZ's matrix of math nodes:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\definecolor{myblue}{RGB}{42,87,102}

\begin{document}

\begin{tikzpicture}
\matrix[
  matrix of math nodes,
  row sep=-\pgflinewidth,
  nodes={
    draw,
    text width=1cm,
    align=center,
    minimum height=30pt
  }
  ] (mat)
  {
    1 & 2 & |[fill=myblue,font=\color{white}]|3 & 4 & 5 & 6 & 7 \\
  };
\draw[<->,>=latex]
  ([yshift=20pt]mat-1-1.north west) 
    node[anchor=north west,font=\scriptsize,inner xsep=0pt] {Lower Reward Potential}
    node[anchor=south west,font=\scriptsize,inner xsep=0pt] {Lower Risk}
    --
  ([yshift=20pt]mat-1-7.north east)
    node[anchor=north east,font=\scriptsize,inner xsep=0pt] {Higher Reward Potential}
    node[anchor=south east,font=\scriptsize,inner xsep=0pt] {Higer Risk}
  ;
\end{tikzpicture}

\end{document}

enter image description here

  • 2
    Amazing job. And exactly like my example. Many thanks – harryg Mar 3 '15 at 15:48
5

Two TikZ-free options:

  1. First, using some defined boxes and \xleftrightarrow:

    \documentclass{article}
    \usepackage{xcolor}
    \usepackage{mathtools}
    
    \definecolor{myblue}{RGB}{42,87,102}
    
    \newcommand\MyBox[2][white]{\fcolorbox{black}{#1}{\rule[-0.35cm]{0pt}{1cm}\makebox[1cm]{{#2}}}}
    
    \begin{document}
    
    \begin{minipage}{\dimexpr7cm+14\fboxsep+11\fboxrule\relax}
    {\scriptsize Lower Risk\hfill Higher Risk\par\vskip-1.5ex}
    $\xleftrightarrow{\hspace*{\dimexpr7cm+40pt\relax}}$\par\vskip-0.45ex
    {\scriptsize Lower Reward Potential\hfill Higher Reward Potential\par\medskip}
    
    \MyBox{1}%
    \hspace*{-0.5\fboxrule}\MyBox{2}%
    \hspace*{-0.5\fboxrule}\MyBox[myblue]{\textcolor{white}{3}}%
    \hspace*{-0.5\fboxrule}\MyBox{4}%
    \hspace*{-0.5\fboxrule}\MyBox{5}%
    \hspace*{-0.5\fboxrule}\MyBox{6}%
    \hspace*{-0.5\fboxrule}\MyBox{7}%
    \end{minipage}
    
    \end{document}
    

    enter image description here

  2. Second, using a tabular and \xleftrightarrow:

    \documentclass{article}
    \usepackage[table]{xcolor}
    \usepackage{array}
    \usepackage{mathtools}
    
    \definecolor{myblue}{RGB}{42,87,102}
    
    \begin{document}
    
    {
    \renewcommand\arraystretch{2}
    \setlength\tabcolsep{0pt}
    \begin{tabular}{*{7}{|>{\centering\arraybackslash}p{1.5cm}}|}
    \multicolumn{7}{p{10.5cm}}{%
    {\scriptsize Lower Risk\hfill Higher Risk\par\vskip-3.5ex}
    $\xleftrightarrow{\hspace*{10.3cm}}$\par\vskip-0.45ex
    {\scriptsize Lower Reward Potential\hfill Higher Reward Potential\par\medskip}
    } \\[-3ex]
    \hline
    1 & 2 &\cellcolor{myblue}\textcolor{white}{3} & 4 & 5 & 6 & 7 \\
    \hline
    \end{tabular}
    }
    
    \end{document}
    

    enter image description here

2

Another option: MetaPost, here in a LuaLaTeX program.

Here N gives the number of boxes, n the box which must be filled, len and h are the dimensions of a box. To be adapted at will.

\documentclass{standalone}
\usepackage{luamplib}
    \mplibsetformat{metafun}
    \mplibtextextlabel{enable}
\usepackage{xcolor}
    \definecolor{myblue}{RGB}{42,87,102}
\begin{document}
\begin{mplibcode}
n := 3; N := 7; len := 2cm; h := 1.5cm;
beginfig(1);
    path box; box = origin -- (len, 0) -- (len, h) -- (0, h) -- cycle;
    draw subpath (3, 4) of box;
    for i = 1 upto N:
        draw image(
            if i <> n:
                draw subpath (0, 3) of box;
                label("{\huge" & decimal i & "}", center box);
            else:
                fill box withcolor \mpcolor{myblue}; draw box;
                label("{\huge" & decimal i & "}", center box) withcolor white;
            fi) shifted ((i-1)*len, 0);
    endfor;
    pair arrow_offset; arrow_offset := (0, h + \mpdim{1.5\bigskipamount});
    path arrow; arrow = (origin -- N*len*right) shifted arrow_offset; drawdblarrow arrow;
    labeloffset := 0bp; pair offset; offset = (0, 4bp);
    label.lrt("Lower Reward Potential", point 0 of arrow) shifted -offset;
    label.llft("Higher Reward Potential", point 1 of arrow) shifted -offset;
    label.urt("Lower Risk", point 0 of arrow) shifted offset;
    label.ulft("Higher Risk", point 1 of arrow) shifted offset;  
    setbounds currentpicture to boundingbox currentpicture enlarged 3mm;
endfig;
\end{mplibcode}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.