I need to make several Plots to show convergence. One of those needs to be opaque with a white circle in the middle where alpha is not allowed.

In the code you can see what i'm thinking about. The circle should be in the background though. Axis labels etc should be in the upper layer.

I have also tried to do it with fill between commands though i didn't get it to work.

MWE

\documentclass[a4paper]{scrartcl}
\usepackage{tikz,pgfplots}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{intersections}
\usetikzlibrary{backgrounds}
\usepackage{graphicx}
\begin{document}
    \begin{tikzpicture}[background rectangle/.style={fill=gray!50}, show background rectangle]
    \begin{axis}[   
        width=1.3\linewidth,
        xmin=-2,
        xmax=2,
        ymin=-2,
        ymax=2,
        axis equal,
        axis lines=middle,
        xlabel=Re($z$),
        ylabel=Im($z$),
        disabledatascaling]
        \fill [white] (0,0) circle [radius=0.8];
        \end{axis}
    \end{tikzpicture}
\end{document}

you mean something like this?

enter image description here

above image is obtain with use of the option axis on top. in code is corrected the image width. now is not wider than the width of text.

\documentclass[a4paper]{scrartcl}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{fillbetween}

\usetikzlibrary{backgrounds,
                intersections}

\begin{document}
    \begin{tikzpicture}[
background rectangle/.style={fill=gray!50}, show background rectangle]
\begin{axis}[
    width=\linewidth,
    xmin=-2,
    xmax= 2,
    ymin=-2,
    ymax= 2,
    axis equal,
    axis lines=middle,
    xlabel=Re($z$),
    ylabel=Im($z$),
    disabledatascaling,
    axis on top]                % <---
    \fill [white] (0,0) circle [radius=0.8];
    \end{axis}
\end{tikzpicture}
\end{document}

Here is a solution based on even odd rule, which avoids filling first gray and then white on top, and is thus arguably closer to what's asked in the title: "Fill everything except a circle in the middle of the plot".

\documentclass[a4paper]{scrartcl}
\usepackage{tikz,pgfplots}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{intersections}
\usetikzlibrary{backgrounds}
\usepackage{graphicx}
\begin{document}
    \begin{tikzpicture}[background rectangle/.style={fill=gray!50,even odd rule,
    insert path={(0,0) circle [radius=3]}},
     show background rectangle]
    \begin{axis}[at={(0,0)},anchor=center,   
        width=1.3\linewidth,
        xmin=-2,
        xmax=2,
        ymin=-2,
        ymax=2,
        axis equal,
        axis lines=middle,
        xlabel=Re($z$),
        ylabel=Im($z$),
        disabledatascaling]

        \end{axis}
    \end{tikzpicture}
\end{document}

enter image description here

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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