I am trying to shade in the area of a circle that is cut into three pieces. Here is the code.
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{tkz-euclide}
\usetikzlibrary{arrows,shadows,positioning, calc, decorations.markings,
hobby, quotes,angles,decorations.pathreplacing,intersections}
\usepgfplotslibrary{polar}
\usepgflibrary{shapes.geometric}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}[scale=1.25,line width=1pt]
\begin{axis}[
color= white,
xmin=-15,
xmax=15,
ymin=-15,
ymax=15,
axis equal image,
axis lines=middle,
xticklabels={},
yticklabels={},
font=\scriptsize,
ticks=none,
xlabel = {},
ylabel = {},
inner axis line style={stealth-stealth}
]
\draw[black, thick, name path=1] (0,0) circle [radius=12];
\addplot[black, domain=-12:12, samples=300, name path = 1] {sqrt(144-x^2)};
\addplot[black, domain=-12:12, samples=300, name path = 2] {-sqrt(144-x^2)};
\draw[white, name path=3] (-12,0) -- (12,0);
\draw[black, dashed] (-3.179,-11.5713) -- (-3.179,11.5713);
\draw[black, dashed] (3.179,-11.5713) -- (3.179,11.5713);
%\addplot[red, fill opacity=0.20] fill between [of=1 and 2,soft clip=
{domain=-12:-3.179}];
\end{axis}
\end{tikzpicture}
\caption{Slicing the pie into three pieces of equal area.}
\label{pie}
\end{figure}
\end{document}
Here is the image produced when I leave the last part commented out:
Now, when I uncomment out the last line, this is the result.
While I have the desired shading, the image is now slightly off-center and the axis lines have been drawn, even though I do not want them to. What should I do to fix this?
Best Answer
As for the original question:
fillbetween
is less "innocent" than one may think, it also sets layers in such a way that the fills are behind the plots. (This is something that I learned from a comment by Stefan Pinnow.) However, the simplest way to get rid of the axes is to sayhide axis
.Yet, if you do not want the axes, why don't you just draw the thing with
tikz
? (In any case, I'd recommend using polar coordinates for that.)Please note also that one can use the pgfplots library
fillbetween
, see e.g. here. (I'm not claiming that this answer is particularly original, it is just an example that I had at hand.)As for your last comment: this is what I suggested
and this is what I get