-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Firstly, great plugin! It is awesome to be able to add tikz diagrams to my notes.
Spotted a little quirk when trying to draw circles with origin and radius relative to axes, using pgfplot.
Instead of circles, it gives elongated ellipses, that are also rotated. eg:
generated by..
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{quotes}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis equal,
xmin=-5,xmax=5,
ymin=-5,ymax=5,
axis lines=middle,
xlabel={$x$},ylabel={$y$}]
\draw[green, thick] (0,0) circle [radius=1];
\node[green, above, right] at (60.5^0.5,60.5^0.5) {$r=1$}; %11 from origin
\draw[red, thick] (0,0) circle [radius=2];
\node[red, above, right] at (72^0.5,72^0.5) {$r=2$}; %12 from origin
\draw[blue, thick] (0,0) circle [radius=-5];
\node[blue, above, right] at (12.5^0.5,12.5^0.5) {$r=-5$}; %5 from origin
\end{axis}
\end{tikzpicture}
\end{document}
The minimum width of the ellipse matches the radius value used.
But the maximum length is being affected by the xmin/max and ymin/max values used, which should not be so.
I've not worked out the exact relationship, but in the example the length is given by: radius + 10 where the 10 is related to the x/y axis lengths (both 10 in this case).
So the only way to get a circle is using radius=-5, as included in the example, but of course a negative radius does not make a lot of sense. And we cannot make circles of any other size this way.
These ellipses are also rotated, by 45 degrees in the case where axes are the same length, but different angles for other arrangements.
As a workaround, we can instead draw a circle using a function, which works as intended, eg:
\addplot[domain=0:360,samples=100] ({cos(x)}, {sin(x)});