LaTeX forum ⇒ Graphics, Figures & TablesDrawing a circle with tikz Topic is solved

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

Drawing a circle with tikz

Postby Suomenlinna » Fri Apr 03, 2015 4:15 pm

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:
  1. \documentclass[12pt,a4paper]{scrartcl}
  2. \usepackage{tikz}
  3. \begin{document}\begin{tikzpicture}
  4.  
  5. \def \n {5}
  6. \def \radius {1cm}
  7.  
  8. \foreach \s in {1,...,\n}
  9. {
  10. \node at ({360/\n * (\s - 1)}:\radius) {$\s$} ;
  11. \draw[-, >=latex] ({360/\n * (\s - 1)}:\radius)
  12. arc ({360/\n * (\s - 1)}:{360/\n * (\s)}:\radius);
  13. }
  14.  
  15. \foreach \from/\to in {1/2,3/5}
  16. \draw ({360/\n * (\from - 1)}:\radius) -- ({360/\n * (\to - 1)}:\radius);
  17.  
  18.  
  19. \end{tikzpicture}
  20. \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!

Tags:

User avatar
Stefan Kottwitz
Site Admin
Posts: 9416
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sun Apr 05, 2015 8:51 pm

Welcome to the forum!

  1. You could simply apply a factor to the radius:
    1. \node at ({360/\n * (\s - 1)}:1.25\radius) {$\s$} ;

  2. circle-1.png
    circle-1.png (10.41 KiB) Viewed 4024 times


  3. You could change the straight line -- to to [bend left=60] to get a rounded line:

    1. \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 4024 times


    Adjust the number to get a smaller or larger angle.

Stefan
Site admin

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

Postby Suomenlinna » Mon Apr 06, 2015 10:12 am

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

Thank you!

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

Postby Suomenlinna » Mon Apr 13, 2015 4:56 pm

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: 9416
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Mon Apr 13, 2015 8:56 pm

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
Site admin


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 3 guests