The following code displays the graph of the polar equation r(\theta) = 4 - 2*sin(\theta)
. I have the region bounded by this curve shaded. I want only the region bounded by this curve and the circle centered at 0 with radius 3 to be shaded.
The radius of the polar axis is 7. I did not specify this. Is the default value one more than the maximum radius of the graph? How do I get the radius of the polar axis to be 8?
I did not specify the dimensions of the plot. It is bigger than I want. How do I get it to be two-thirds the current display size? Can the dimensions be specified by specifying the number of centimeters or inches for the height and width?
Why is there a small black arc – maybe between -5 degrees and 5 degrees drawn at a radius slightly more than 4?
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[
clip=false, major grid style={black}, minor x tick num=3, % 3 minor x ticks between majors
minor y tick num=2, % 2 minor y ticks between majors
grid=both,
xtick={0,45,...,315},
xticklabels={, $\frac{\pi}{4}$, , $\frac{3\pi}{4}$, , $\frac{5\pi}{4}$, , $\frac{7\pi}{4}$},
ytick={0,3,6},
yticklabels={\empty}
]
\addplot[samples=360, mark=none, fill=red!70!black, opacity=0.5, domain=0:360] {4 - 2*sin(\x)};
\addplot[samples=360, mark=none, thick, red!70!black, domain=0:360] {4 - 2*sin(\x)};
\addplot[samples=360, draw=red, thick, mark=none, domain=0:360] {3};
\addplot[black] {4.05};
\end{polaraxis}
\end{tikzpicture}
\end{document}
Best Answer
There are so many minor questions. Tell me if any part in this answer is unclear.
See the code at the end. Essentially you can either
\clip
or plot a new functionmin(4-2*sin(\x),3)
Noone really knows. The determination of the axis limit is a long-standing mystery of pgfplots.
Answered by @Bobyandbob in the comment. (This is perhaps the least pathetic way to control the axis limit.)
Use
\begin{polaraxis}[width=5cm]
or whatever value you want.Because
\addplot[black] {4.05};
in your MWE. Recall that the defaultdomain
is-4:4
in TikZ.Strictly speaking in
polaraxis
there are only r-axis and θ-axis. To draw the usual x-axis, use\draw[->]
. (See the code below.) The labels on the x-axis can be drawn by something like\draw foreach\x in{-10,...,10}{(0,\x)node[lower right]{x}};
This can be done by TikZ's
double
. You can control it byline width
anddouble distance
. (See the code below.)code