# Graphing Areas of Integration [duplicate]

Is there a better way to plot a graph and shade a particular area? I've pieced what follows below from other answers, but when I try to extend the axes beyond the plot itself, the whole circle becomes shaded.

\documentclass[15pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{width=10cm,compat=1.16}
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{#1}}
\makeatother
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
data cs=polar,
smooth,
axis lines = center,
xlabel = $x$,
ylabel = {$y$},]
\path[name path=axis] (axis cs:-3,0) -- (axis cs:3,0);
thick,
color=red,
fill=red,
fill opacity=0.5
]
fill between[
of=f and axis,
soft clip={domain=-3:3},
];

\end{axis}
\end{tikzpicture}

\end{center}

\end{document}


Thanks!

## marked as duplicate by TeXnician, Stefan Pinnow, Kurt, Mike Renfro, Phelype OleinikMay 20 '18 at 18:22

• Welcome to TeX.SE!. It would be very uselful if you make your code compilable, by adding \documentclass{...} and ending with \end{document}. – Cragfelt May 20 '18 at 7:15
• I'll add it, but I'm sort of embarrassed by the potentially redundant preamble... – Chris Swan May 21 '18 at 10:02

is this what you after for?

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{intersections}

\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
data cs=polar,
smooth,
axis lines = center,
axis equal,
xlabel = $x$,
ylabel = {$y$},
ymin=-2.5, ymax=2.5
]
\addplot [name path=f, domain=0:180]    {2}; % <--- changed
\addplot [domain=180:360]               {2}; % <--- new
\path[name path=axis] (-3,0) -- (3,0);