Graphics, Figures & TablesDrawing a circle with tikz

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Suomenlinna
Posts: 3
Joined: Fri Apr 03, 2015 3:26 pm

Drawing a circle with tikz

Post by Suomenlinna »

Hi everyone,
I'm trying to draw a circle with tikz.
I've tried to adapt this example: http://www.texample.net/tikz/examples/cycle/
My circle should satisfy the following properties:
(1) There should be, for a fixed $n$, $n$ invisible vertices (with equal distance) on the circle line. Moreover, these vertices should be numbered from $1$ up to $n$ (but the numbers should not be on the circle line, but a little outside.
(2) Some pairs of vertices should be connected. These connecting edges should be within the circle.

So far I have got this far:

Code: Select all

\documentclass[12pt,a4paper]{scrartcl}
\usepackage{tikz}
\begin{document}\begin{tikzpicture}

\def \n {5}
\def \radius {1cm}

\foreach \s in {1,...,\n}
{
  \node at ({360/\n * (\s - 1)}:\radius) {$\s$} ;
  \draw[-, >=latex] ({360/\n * (\s - 1)}:\radius) 
    arc ({360/\n * (\s - 1)}:{360/\n * (\s)}:\radius);
}

\foreach \from/\to in {1/2,3/5}
\draw ({360/\n * (\from - 1)}:\radius) -- ({360/\n * (\to - 1)}:\radius);


\end{tikzpicture}
\end{document}
Now, I have two problems:
(1) The numbers 1,...,5 are on the circle line, not outside. This looks not good in my opinion. Is there a way to change that?
(2) If I increase $n$ to, say, 15, and two consecutive numbers (like 1 and 2 in my example) are connected, then you can't see the connecting vertex that well. Therefore, I would like to connect consecutive vertices not with a straight line, but with a "more round line" that goes a little bit into the circle. I hope it's understandable what I mean by that.

Thanks in advance!

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

Stefan Kottwitz
Site Admin
Posts: 10334
Joined: Mon Mar 10, 2008 9:44 pm

Drawing a circle with tikz

Post by Stefan Kottwitz »

Welcome to the forum!
  1. You could simply apply a factor to the radius:

    Code: Select all

    \node at ({360/\n * (\s - 1)}:1.25\radius) {$\s$} ;
  2. [attachment=1]circle-1.png[/attachment]
  3. You could change the straight line -- to to [bend left=60] to get a rounded line:

    Code: Select all

    \draw ({360/\n * (\from - 1)}:\radius) to [bend left=60] ({360/\n * (\to - 1)}:\radius);
    circle-2.png
    circle-2.png (14.59 KiB) Viewed 9008 times
    Adjust the number to get a smaller or larger angle.
Stefan
Attachments
circle-1.png
circle-1.png (10.41 KiB) Viewed 9008 times
LaTeX.org admin
Suomenlinna
Posts: 3
Joined: Fri Apr 03, 2015 3:26 pm

Re: Drawing a circle with tikz

Post by Suomenlinna »

Thank you very much, it does work just like I expected!

Thank you!
Suomenlinna
Posts: 3
Joined: Fri Apr 03, 2015 3:26 pm

Re: Drawing a circle with tikz

Post by Suomenlinna »

Okay, I seem to have another question/problem:

I want to connect two nodes, say 1 and 2 with an arc - but so that the center of the cirle is contained in this sector of the circle.

So, is there a way to draw an (invisible) node at, say, P=({360/\n * (4 - 1)}:0.3\radius) and draw a (smooth) arc through 1, P and 2?

I hope you can understand my question.

Best regards,
Suomenlinna
User avatar
Stefan Kottwitz
Site Admin
Posts: 10334
Joined: Mon Mar 10, 2008 9:44 pm

Drawing a circle with tikz

Post by Stefan Kottwitz »

Hi Suomenlinna,
Suomenlinna wrote:Okay, I seem to have another question/problem
we don't sort questions per user, but per topic. You see, this topic is "Drawing a circle with tikz", matching the original question fine, but who shall now expect something about drawing an arc through some points? Or how many readers may see it at all, at the bottom of a solved topic? I can split it later on, so don't miss the new topic, you may look at "View your posts" at the right menu, or your profile, to find it. For now, this message, let's see if some helper finds the way here or then to the fresh one (possibly I as well).

Feel free to open a new topic for each new question. We got space for millions of topics. And it's easier to sort and to find (than on page 6 of an old topic ;-) )

Stefan
LaTeX.org admin
Post Reply