Question: Here i am trying to fill quadrants of a circle with different colors, i have started with scope but didn't get success. How can i achieve this?
MWE:
\documentclass[12pt]{article}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\usepgfplotslibrary{fillbetween}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,scale=.9,x=1cm,y=1cm]
\begin{axis}[
x=1cm,y=1cm,
axis lines=middle,
axis line style={stealth-stealth},
xmin=-5,
xmax=5,
ymin=-5,
ymax=5.0,
xtick=\empty,
ytick=\empty,]
\draw [line width=0.8pt,color=black] (0,0) circle (3cm);
%Fill color
\begin{scope}
\fill[orange] (3,0) rectangle (0,3);
\end{scope}
%Labelling of endpoints and curve
\draw[color=black] (-3.0,3.0) node {$x^2+y^2=9$};
\draw [fill=black] (0,0) circle (2.5pt);
\draw[color=black] (0.8,-0.6) node {$O(0 , 0)$};
\draw [fill=black] (3,0) circle (2.5pt);
\draw[color=black] (3.8,0.4) node {$A(3 , 0)$};
\draw [fill=black] (0,3) circle (2.5pt);
\draw[color=black] (0.70,3.40) node {$B(0 ,3)$};
\draw [fill=black] (-3,0) circle (2.5pt);
\draw[color=black] (-4.0,0.30) node {$C(-3 , 0)$};
\draw [fill=black] (0,-3) circle (2.5pt);
\draw[color=black] (1,-3.40) node {$D(0 , -3)$};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
Tikz
allows you to cut the frame (paper) on which you draw with theclip
operation. All drawings made after the cutting only appear in the cut area.Here, it is enough to cut before coloring.
You will notice that this overwrites the black discs marking points A, B, C and D.
Edit:
To avoid this problem, it is enough to perform the cutting within a scope environment. This allows you to continue drawing on the entire frame after leaving this scope.
Edit 2: more explanations
The scope environment creates a subset of the drawing, i.e. it delimits a part of the drawing.
So there are now two parts in the drawing (frame):
By creating a scope environment and cutting it into a circle, tikz is asked to limit the coloring within this circle.
Once out of this environment, we draw again on the whole page (frame).