# Tikz/pgfplots shade to origin (polar)

I'm trying to shade in just one petal of a polar function. Specifically, I was wondering if there was a way to shade in the bounded region that lives between my two rays:

I've tried searching for examples elsewhere but most of the ones I've seen involve either shading in a region bounded by two curves or shading in the area under a function y=f(x).

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
smooth,
axis lines=middle,
axis equal]
({2*sin(5*x)*cos(x)}, {2*sin(5*x)*sin(x)});
\draw [-stealth, ultra thick, dashed, draw=blue]
(axis cs: 0,0)
\draw [-stealth, ultra thick, dashed, draw=blue]
(axis cs: 0,0)
\end{axis}
\end{tikzpicture}%
\end{document}


Any feedback would be greatly appreciated!

• Welcome to Tex.SE !! – nidhin Oct 27 '19 at 5:54

Since you know the coordinates, just use fill.

\fill[blue,opacity=0.4] (o) -- (a) -- (b);


Note that I have the named the coordinates. See the full code:

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
smooth,
axis lines=middle,
axis equal]
\addplot [domain=0:pi, samples=150, red] ({2*sin(5*x)*cos(x)}, {2*sin(5*x)*sin(x)});
\draw [-stealth, ultra thick, dashed, draw=blue] (axis cs: 0,0)coordinate(o)
\draw [-stealth, ultra thick, dashed, draw=blue] (o)
\fill[blue,opacity=0.4] (o) -- (a) -- (b);
%  for filling the petal
% \addplot [domain=0:pi/5, samples=30, red,fill=blue!40] ({2*sin(5*x)*cos(x)}, {2*sin(5*x)*sin(x)});
\end{axis}
\end{tikzpicture}%
\end{document}


Output:

### EDIT

If you want only the petal to be shaded, then you can use the \addplot to fill.

\addplot [domain=0:pi/5, samples=30, red,fill=blue!40] ({2*sin(5*x)*cos(x)}, {2*sin(5*x)*sin(x)});


• thanks! I should've been more clear in my question. I only wanted to shade in just the region bounded by the function. Specifically, I just want to shade in the petal. – Donnie Nathan Chad Oct 27 '19 at 13:02
• @DonnieNathanChad See the edit. – nidhin Oct 27 '19 at 13:23

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[