3

I have following code:

\begin{tikzpicture}[]
\begin{polaraxis}[xtick={0,90,180,270}, ytick={0,1}, ymax=1.5, xticklabel={\pgfmathprintnumber{\tick}\si{\degree}}, set layers=default]
\addplot[thick,fill=gray,draw=none,opacity=0.5,  domain=0:360,
samples=360,]{1};
\addplot+[thick, mark=none, >->] table[col sep=comma,x=ang,y=abs] {images/tikz/stability/stable.csv};
\addplot+[thick, mark=none, >->, orange] table[col sep=comma,x=ang,y=abs] {images/tikz/stability/instable.csv};
\end{polaraxis}
\end{tikzpicture}

It draws some plots to a polar plot. With the first plot I try to fill the inner of the unit circle. However, I have not succeeded in doing so. I want the circle to be behind the axis. For this, I tried set layers in the options of the axis environment.

The first problem I experience is that: set layers=defautl and set layers should have the same effect, according to the documentation, but they don't. With set layers (without default), the axes vanish. with default the axes stay.

With the key on layer=axis background I tried to move the first plot behind the axes, as described here.

This does not work because the layer is unknown. I then tried set layers=standard. With this setting, the layer name is known, but the axes disappear again.

Can someone tell me, how to draw a plot behind polar axes?

Thank you

EDIT:

I've created a mimimal (not) working example with three varieties of code. The first two images should create the same output but they don't. The last one doen't do anything.

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{pgfplotstable}
\usepgfplotslibrary{polar}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[]
\begin{polaraxis}[xtick={0,90,180,270}, ytick={0,1}, ymax=1.5, set 
layers=default]
\addplot[thick,fill=gray,draw=none,opacity=0.5,  domain=0:360,
samples=360,]{1};
\end{polaraxis}
\end{tikzpicture}

\begin{tikzpicture}[]
\begin{polaraxis}[xtick={0,90,180,270}, ytick={0,1}, ymax=1.5, set 
layers]
\addplot[thick,fill=gray,draw=none,opacity=0.5,  domain=0:360,
samples=360,]{1};
\end{polaraxis}
\end{tikzpicture}

\begin{tikzpicture}[]
\begin{polaraxis}[xtick={0,90,180,270}, ytick={0,1}, ymax=1.5, set 
layers=standard]
\addplot[thick,fill=gray,draw=none,opacity=0.5,  domain=0:360,
samples=360, on layer=axis background]{1};
\end{polaraxis}
\end{tikzpicture}
\end{document}
5
  • Please provide a complete MWE (and try axis on top). Nobody has stable.csv, so please also add a short csv file.
    – user121799
    Commented Oct 12, 2018 at 21:02
  • The code does the same thing without the two csv files. You can just comment these lines, but I will try to create a MWE.
    – GNA
    Commented Oct 12, 2018 at 21:04
  • If I comment out the two csv files, then the circle is on the background.
    – user121799
    Commented Oct 12, 2018 at 21:05
  • I want the circle to be behind the axis and the plots in front of the axis. But the documentation is wrong. axis on top helps, but in this case all plots are in front of the axis, which is not what I want.
    – GNA
    Commented Oct 12, 2018 at 21:07
  • Writing 'set layers' causes the axis to completely disappear. I only get the gray filled circle.
    – GNA
    Commented Oct 12, 2018 at 21:08

1 Answer 1

4

Now I can confirm your observation: the layers on polar plots do not work as expected. As a workaround, one can draw the grid by hand on the axis layer.

\documentclass[tikz,3.14mm]{standalone}
\usepackage{siunitx}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.16}
\usepgfplotslibrary{polar} 
\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[xtick={0,90,180,270}, ytick={0,1}, ymax=1.5,
xticklabel={\pgfmathprintnumber{\tick}\si{\degree}},
 axis on top,grid style={draw=none}]
\addplot[thick,fill=red,draw=none,opacity=0.5,  domain=0:360,
samples=360,]{1};
% draw grid by hand
\begin{scope}[on layer=axis lines,thin,gray]
\draw(180,2) -- (0,2) (90,2) -- (270,2) (0,0);
\addplot[domain=0:360,samples=60,smooth]{1};
\end{scope}

\begin{scope}[on layer=axis foreground]
\addplot[thick,domain=0:360] {sin(x)};
\end{scope}
% \addplot+[thick, mark=none, >->] table[col sep=comma,x=ang,y=abs] {images/tikz/stability/stable.csv};
% \addplot+[thick, mark=none, >->, orange] table[col sep=comma,x=ang,y=abs] {images/tikz/stability/instable.csv};
\end{polaraxis}
\end{tikzpicture}
\end{document}

enter image description here

As you see, the filled circle is on the background, i.e. behind the grid, but the plot is on the foreground.

7
  • It is a nice approach. However, the axis is still drawn in front of the two plots. Even with on layer=axis foreground. It does not work
    – GNA
    Commented Oct 12, 2018 at 21:22
  • @GNA You are right, there is indeed an issue. I looked through tikzlibrarypgfplots.polar.code.tex and did not find an obvious way to modify the grid drawing there, so the best thing I can offer is a workaround.
    – user121799
    Commented Oct 12, 2018 at 21:51
  • The best can't stay with a score of zero. +1.
    – Sebastiano
    Commented Oct 12, 2018 at 21:52
  • @Sebastiano Mille grazie but this is not an answer by egreg. ;-)
    – user121799
    Commented Oct 12, 2018 at 21:52
  • @marmot With all my sincerity you will reach the skill of nr. 1 as egreg.
    – Sebastiano
    Commented Oct 12, 2018 at 21:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .