TeX - LaTeX Asked by steglitz on June 14, 2021
I am having trouble drawing a simple circle on a graph using tikz. When I try cases from the documentation or other examples from different questions, I get a diagonal ellipse. Here’s what I have so far.
documentclass[12pt]{extarticle}
usepackage{tikz}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}[scale=0.8]
begin{axis}[
axis y line=center,
axis x line=middle,
axis on top=false,
xmin=-6.5, xmax=6.5,
ymin=-6.5, ymax=6.5,
grid,
xtick={-6,...,6},
xticklabels={-6,...,6},
ytick={-6,...,6},
yticklabels={-6,...,6},
]
draw (0,0) circle [radius=3];
end{axis}
end{tikzpicture}
end{document}
I end up with a diagonal ellipse when I use radius like so:
Then I tried using the ellipse format where I changed draw (0,0) circle [radius=3];
to draw (0,0) circle (45pt and 45pt);
As you can see from my result,
I get a circle, but it only seems to line up on the x-axis, and it overshoots the y-axis. Is the graph not actually square, or is it the formatting for the circle that’s creating problems?
It would seem that keeping the draw (x,y) circle[radius=?]
worked just fine after adding axis equal image
to my code. My final working version is:
usepackage{tikz}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}[scale=0.8]
begin{axis}[
axis y line=center,
axis x line=middle,
axis on top=false,
axis equal image,
xmin=-6.5, xmax=6.5,
ymin=-6.5, ymax=6.5,
grid,
xtick={-6,...,6},
xticklabels={-6,...,6},
ytick={-6,...,6},
yticklabels={-6,...,6},
]
draw (1,3) circle[radius=37pt];
end{axis}
end{tikzpicture}
end{document}
By keeping the draw inside the axis, I didn't have any additional problems with positioning the circle.
Correct answer by steglitz on June 14, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP