I am curious about the misinterpretation of TikZ
commands to draw and label an angle in an axis
environment. If, in the following code, I have $\theta$ drawn using the commands,
\draw[draw=blue] (A) ++(120:4mm) arc (120:0:4mm);
\coordinate (label_for_theta) at (60:5.5mm);
\node[font=\footnotesize] at (label_for_theta){$\theta$};
the angle and label are displayed as expected. I have, though,
\draw[draw=blue] (A) ++(120:0.4) arc (120:0:0.4);
\coordinate (label_for_theta) at (60:0.55);
\node[font=\footnotesize] at (label_for_theta){$\theta$};
and a mess is displayed. I understand that using the axis
environment is superfluous – I am using it just to draw the axes. As I said, I am curious. (I know that I could use tkz-euclice
. I am using this as an opportunity to get familiar with TikZ
. I would prefer to avoid using this package, anyway.)
By the way, I typeset the vertex A
properly with \node at (0.25,-0.25){$A$};
, without units, and I typeset the vertex B
properly with \node at (3.5,-2.5mm){$B$};
, with units. I was told that specifying coordinates with dimensions within an axis environment would be misinterpreted.
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=5in,axis equal image,
axis lines=middle,
xmin=-5,xmax=5,
ymin=-1.5,ymax=5,
restrict y to domain=-1.5:5,
xtick={\empty},ytick={\empty},
axis line style={latex-latex},
xlabel=$x$,ylabel=$y$,
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
%A triangle is drawn on the Cartesian plane. One side of the triangle is along
%the positive x-axis, and another side of the triangle is drawn in Quadrant II.
\coordinate (A) at (0,0);
\coordinate (B) at (3.5,0);
\coordinate (C) at ({5*cos(120)},{5*sin(120)});
\draw (A) -- (B) -- (C) -- cycle;
%The labels for A and B are typeset.
\node at (0.25,-0.25){$A$};
\node at (3.5,-2.5mm){$B$};
%The label for C is typeset.
\coordinate (label_C_left) at ($(C)!-4mm!(B)$);
\coordinate (label_C_right) at ($(C)!-4mm!(A)$);
\coordinate (label_C) at ($(label_C_left)!0.5!(label_C_right)$);
\node[blue] at ($(C)!2.5mm!(label_C)$){$C$};
%Angles are drawn for $\theta$ and its supplement.
\draw[draw=blue] (A) ++(120:0.4) arc (120:0:0.4);
\coordinate (label_for_theta) at (60:0.55);
\node[font=\footnotesize] at (label_for_theta){$\theta$};
\draw[draw=blue,dash dot] (A) ++(180:0.6) arc (180:120:0.6);
\coordinate (label_for_supplement_to_theta) at (150:0.75);
\node[font=\footnotesize] at (label_for_supplement_to_theta){$\pi - \theta$};
%A right-angle mark is drawn.
\coordinate (U) at ($(-2.5,0)!3mm!45:(A)$);
\draw[dash dot] (U) -- ($(-2.5,0)!(U)!(A)$);
\draw[dash dot] (U) -- ($(-2.5,0)!(U)!(C)$);
\draw[dashed] (C) -- (-2.5,0);
%Braces indicating the distances that C is from the axes are typeset. To give
%them the appearance of being typeset over the axes, they are first typeset
%in white with a line width of 2pt, which is 10 times the thickness of the
%brace that is actually typeset.
\draw[draw=white,line width=4pt,decorate,decoration={brace,raise=5pt,amplitude=5pt}] (-2.5,0) -- (C);
\draw[decorate,decoration={brace,raise=5pt,amplitude=5pt}] (-2.5,0) -- (C);
\draw[draw=white,line width=4pt,decorate,decoration={brace,raise=5pt,amplitude=5pt,mirror}] (-2.5,0) -- (A);
\draw[decorate,decoration={brace,raise=5pt,amplitude=5pt,mirror}] (-2.5,0) -- (A);
\coordinate (label_for_5_sin_theta) at ($({5*cos(120)},{2.5*sin(120)}) + (-2.5mm-10pt,0pt)$);
\node[anchor=east] at (label_for_5_sin_theta){$r\sin\theta$};
\coordinate (label_for_5_cos_theta) at (-1.25,-2.5mm-10pt);
\node at (label_for_5_cos_theta){$r\cos\theta$};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
If you only want to use the axis environment to draw the axis, then don't try to do anything else with it. Note: the scope is used to shift the origin.
I also simplified your angle labels. Later I came back and simplified all of the labels.