TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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
up vote 5 down vote accepted

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}.

\usepackage{pgfplots, filecontents}

    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={%
            \coordinate [inner sep=0pt] (errormarknode-\themark) at ##2 {};
                \path [/pgfplots/every error ellipse] let
                    ##1 ellipse [x radius=(\x2-\x1)/2, y radius=(\y4-\y3)/2]

x y errorx errory
1 1 0.1 0.2
3 2 1 0.3
5 2 1 1


    axis equal % So equal x and y errors result in circles
\addplot [
    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};

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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