# pgfplots: marks in table as ellipse with size of error bars, area of uncertainty?

Is it possible, and if yes how, to plot a table with pgfplots where the marks are ellipses with the major and minor semiaxes being the size of the error? Such that a data point is displayed as its own "area of uncertainty". Fading-out towards the edges of the ellipses would be a nice plus but is purely optional.

Unfortunately I can't provide an "already-tried-it-this-way example", because I have absolutely no idea where to start here.

-
If you could provide us with a drawing of what you want to achieve it would be easier to understand what your are trying to achieve. –  DrJay Nov 21 '12 at 8:15

You can use the existing error bar infrastructure to place coordinates at the end points of the major and minor axes of the error ellipses, and then draw the ellipse using a simplified version of Percusse's answer to How to fit ellipse into another object - using intersections and calc library.

Here's an error ellipse style that does this. You can change the style of the error ellipse using the key error ellipse style. To get a faded filling, you could set error ellipse style={inner color=red, outer color=white}.

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots, filecontents}
\usetikzlibrary{calc}

\pgfplotsset{compat=1.5.1}
\newcounter{mark}
\pgfplotsset{
every error ellipse/.style=draw,
error ellipse style/.style={
every error ellipse/.style={#1}
},
error ellipse/.style={
error bars/error mark options={},
/pgfplots/error bars/draw error bar/.code 2 args={%
\stepcounter{mark}
\coordinate [inner sep=0pt] (errormarknode-\themark) at ##2 {};
\ifnum\themark=4
\path [/pgfplots/every error ellipse] let
\p1=(errormarknode-1),
\p2=(errormarknode-2),
\p3=(errormarknode-3),
\p4=(errormarknode-4)
in
;
\setcounter{mark}{0}
\fi
}
}
}

\begin{filecontents}{data.dat}
x y errorx errory
1 1 0.1 0.2
3 2 1 0.3
5 2 1 1
\end{filecontents}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
grid=both,
axis equal % So equal x and y errors result in circles
]
mark=*, only marks,
error ellipse,
error bars/.cd,
x dir=both, y dir=both,
x explicit, y explicit
] table [
x error=errorx, y error=errory
] {data.dat};
\end{axis}
\end{tikzpicture}

\end{document}

-
Wow, nice. Thanks. :) Is it possible to remove the dots in the ellipses? –  Foo Bar Nov 21 '12 at 17:23
@FooBar: Sure, they're just the normal plot marks which don't have anything to do with the error ellipses. Just set no markers, draw=none in the \addplot options instead of only marks, and the dots disappear. –  Jake Nov 21 '12 at 18:35
Where would I have to set the style with the inner and outer color for the fading? I tried putting it everywhere, but it just don't gets displayed... –  Foo Bar Nov 22 '12 at 10:20
@FooBar: You just put error ellipse style={inner color=red, outer color=white} straight after error ellipse in the \addplot options. –  Jake Nov 22 '12 at 10:22
@FooBar: Thanks! By the way, you can also put the error ellipse style={inner color=red, outer color=white} in the axis options if you want the same style for all plots, or you can set it gobally using \pgfplotsset{error ellipse style={inner color=red, outer color=white}} anywhere in your document before the axis. –  Jake Nov 22 '12 at 12:05