pgfplots - filldraw disappears after adding plot

by Felix Jassler   Last Updated May 20, 2018 14:23 PM

I have some plots in my graph and want to mark a special area with a square.

Here's what the plot looks like:

\begin{tikzpicture}
    \begin{axis}[axis lines = left, xlabel = {Player 1}, ylabel = {Player 2}, xmin = 0, xmax = 3.5, ymin = 0, ymax = 3.5]

        \filldraw [draw=none,pattern=north east lines] (200, 200) rectangle (400, 400);

        \addplot [blue, thick]{2};
        \addplot [blue, thick] coordinates {(2,0)(2,3.5)};

        \addplot [color=red, thick]{-x+3};

    \end{axis}
\end{tikzpicture}

graph plots without marked area

The plots render correctly, but the area, which I marked in the picture in green by hand, doesn't appear. However, if I comment out the three addplot commands, the area magically appears:

\begin{tikzpicture}
    \begin{axis}[axis lines = left, xlabel = {Player 1}, ylabel = {Player 2}, xmin = 0, xmax = 3.5, ymin = 0, ymax = 3.5]

        \filldraw [draw=none,pattern=north east lines] (200, 200) rectangle (400, 400);

        % \addplot [blue, thick]{2};
        % \addplot [blue, thick] coordinates {(2,0)(2,3.5)};

        % \addplot [color=red, thick]{-x+3};

    \end{axis}
\end{tikzpicture}

graph area renders without plots

This feels like a bug to me, but maybe I'm just missing some context to know why it isn't working. Is there a way to solve this?



Related Questions


Plotting a graph with several values of a parameter

Updated April 12, 2015 22:10 PM

matplotlib2tikz - compilation error for 2D

Updated April 06, 2015 18:09 PM

Uniformly spaced line markers

Updated May 30, 2015 03:10 AM