Graphics, Figures & TablesDrawing an arc in tikz

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Drawing an arc in tikz

Post by mas »

I am trying to draw a figure like the one attached using Tikz. I have
not been able to place the arc correctly. My code is as follows :

Code: Select all

\documentclass[x11names]{article}
%
\usepackage{tikz}

\begin{document}
  \begin{center}
  \begin{tikzpicture}[scale=1]
    \draw[help lines,step=.5,gray] (-3,-3) grid (3,3) ;
      \foreach \x in {-3,-2.5,...,3}
      \draw (-3,\x) node[left]{\tiny\x} ;
    \foreach \x in {-3,-2.5,...,3}
      \draw (\x,3) node[above]{\tiny\x} ;

    \coordinate (O) at (0,0) ;

    \draw[thin,gray] (O) circle (3cm) ;
    \draw[red,rotate=35,dashed] (O) ellipse (3 and 1) ;

    \node at (-2.7,-2) {A} ;
    \node at (2.7,2) {B} ;

    \draw[blue,rotate=35] (35:3) arc (35:-155:3 and 1) ;
  \end{tikzpicture}
  \end{center}
\end{document}
The orientation of the blue arc is fine, but I am not able to position it so that it starts at B and ends at A.

Can someone point me to the correct way to do it?

Regards,

sridhar
Attachments
path2389.png
path2389.png (28.5 KiB) Viewed 21651 times

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Drawing an arc in tikz

Post by localghost »

mas wrote:[...] Can someone point me to the correct way to do it? [...]
A slight modification to the drawing command for the arch will do the trick.

Code: Select all

\documentclass[x11names]{article}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}[scale=1]
    \draw[help lines,step=.5,gray] (-3,-3) grid (3,3) ;
      \foreach \x in {-3,-2.5,...,3}
      \draw (-3,\x) node[left]{\tiny\x} ;
    \foreach \x in {-3,-2.5,...,3}
      \draw (\x,3) node[above]{\tiny\x} ;

    \coordinate (O) at (0,0) ;

    \draw[thin,gray] (O) circle (3cm) ;
    \draw[red,rotate=35,dashed] (O) ellipse (3 and 1) ;

    \node at (-2.7,-2) {A} ;
    \node at (2.7,2) {B} ;

    \draw[blue,rotate=35] (0,0) +(180:3) arc (180:360:3 and 1) ;
  \end{tikzpicture}

\end{document}
Drawing arches in pgf/tikZ is a little bit tricky because the arch will start at the actual coordinate and not take this coordinate as its center.


Best regards
Thorsten
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Re: Drawing an arc in tikz

Post by mas »

Thanks for the tip and workaround.

Regards,

sridhar

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
Post Reply