# How can I make plots with TikZ which look like the new Mathematica 9 plots

The new Mathematica 9 is out! I would love to know how to make similar plots to the one's advertized, particularly the following: and Here is a simple plot to get started.

%& -shell-escape
\documentclass{article}
\usepackage{tikz}

\begin{filecontents}{data.dat}
3.045784        3.415896
3.405784        4.025693
3.785784        4.522530
4.125784        5.538449
4.485784        6.704992
4.805784        6.978939
5.145784        7.113496
5.425784        8.916397
6.065784        9.487712
6.365784        10.876397
6.685784        10.693497
7.025784        11.364131
7.345784        11.442530
7.665784        12.582530
8.005784        13.125693
8.225784        13.738450
8.585784        14.247891
8.865784        14.982530
\end{filecontents}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}[x=1cm,y=0.4cm]

\def\xmin{3}
\def\xmax{9.2}
\def\ymin{2}
\def\ymax{15.5}

% grid
\draw[style=help lines, ystep=2, xstep=1] (\xmin,\ymin) grid
(\xmax,\ymax);

% axes
\draw[->] (\xmin,\ymin) -- (\xmax,\ymin) node[right] {$x$};
\draw[->] (\xmin,\ymin) -- (\xmin,\ymax) node[above] {$y$};

% xticks and yticks
\foreach \x in {3,4,...,9}
\node at (\x, \ymin) [below] {\x};
\foreach \y in {2,4,...,14}
\node at (\xmin,\y) [left] {\y};

% plot the data from the file data.dat
% smooth the curve and mark the data point with a dot
\draw[color=blue] plot[smooth,mark=*,mark size=1pt] file {data.dat}
node [right] {data};

\end{tikzpicture}

\end{document} • Congrats by the way for a nice graph without pgfplots I was looking for the start of the axis environment :) – percusse Nov 29 '12 at 20:04

Here's a way of doing this with PGFPlots: The first plot is simply a ycomb plot, and the second I would draw using separate plots for the areas (with a trailing \closedcycle to get the filling right) and the lines. \documentclass{article}
\usepackage{pgfplots}
\usepackage{filecontents}

\begin{filecontents}{data.dat}
3.045784        3.415896
3.405784        4.025693
3.785784        4.522530
4.125784        5.538449
4.485784        6.704992
4.805784        6.978939
5.145784        7.113496
5.425784        8.916397
6.065784        9.487712
6.365784        10.876397
6.685784        10.693497
7.025784        11.364131
7.345784        11.442530
7.665784        12.582530
8.005784        13.125693
8.225784        13.738450
8.585784        14.247891
8.865784        14.982530
\end{filecontents}

\begin{document}
\pgfplotsset{
compat=1.5,
width=10cm,
height=5cm
}

\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};

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};
\end{axis}
\end{tikzpicture}

\end{document}


Aha, Jake was way faster.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
enlargelimits=false,
]
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
ymax=7,
]
\draw node[append after command={ (a) -| (axis cs:11,2)}] (a) at (axis cs:6,4) {Global Filtering!};
\end{axis}

\end{tikzpicture}

\end{document} To begin with, I would recommend moving your example to use pgfplots, and then work it out.

\$1000 cheaper you get this (code below) \documentclass{article}
\usepackage{pgfplots}
\usepackage{filecontents}
\begin{filecontents}{data.dat}
3.045784        3.415896
3.405784        4.025693
3.785784        4.522530
4.125784        5.538449
4.485784        6.704992
4.805784        6.978939
5.145784        7.113496
5.425784        8.916397
6.065784        9.487712
6.365784        10.876397
6.685784        10.693497
7.025784        11.364131
7.345784        11.442530
7.665784        12.582530
8.005784        13.125693
8.225784        13.738450
8.585784        14.247891
8.865784        14.982530
\end{filecontents}

\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[x=1cm,y=0.4cm]
\begin{axis}