Example: Mathematica 9 style plots

Published 2014-03-15 | Author: Jake

Here’s a way of doing Mathematica 9 style plots with PGFPlots: the first plot is simply a ycomb plot, and the second we can draw using separate plots for the areas (with a trailing \closedcycle to get the filling right) and the lines.

This code was written by Jake on TeX.SE.

Download as: [PDF] [TEX]  •  [Open in Overleaf]

Mathematica 9 style plots

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de.

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.6}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
    ymin=0,
    xtick=\empty,
    ytick=\empty,
    axis background/.style={fill=gray!10},
  ]
  \addplot [ycomb, red, very thick, mark=*, mark options={red!60!black}] table {data.dat};
  \end{axis}
\end{tikzpicture}

\begin{tikzpicture}
  \begin{axis}[
    ymin=0,
    xtick=\empty,
    ytick=\empty,
    axis background/.style={fill=gray!10},
    enlarge x limits=false
  ]
  \addplot [draw=none, fill=orange!40!yellow] table {data.dat} \closedcycle;
  \addplot [draw=gray, very thick] table {data.dat};

  \addplot [draw=none, fill=red!60] table [
    x expr=\thisrowno{0}+8.865784-3.045784,
    y expr=\thisrowno{1}+14.982530-3.415896
  ] {data.dat} \closedcycle;
  \addplot [draw=red!70!black, very thick] table [
    x expr=\thisrowno{0}+8.865784-3.045784,
    y expr=\thisrowno{1}+14.982530-3.415896
  ] {data.dat};
    \draw node[append after command={ (a) -| (axis cs:10.5,13.5)}, font=\sffamily]
    (a) at (axis cs:6,16) {Forecast};
\end{axis}
\end{tikzpicture}
\end{document}

Comments

Adding comments is currently not enabled.