0

I am writing an essay about partitions of a set. I would like to illustrate partitions on a circle. In order to do that i would like to draw a circle, mark points on it and connect some of them with a line. The desire output would look like this: enter image description here

In my essay I will have a lot of examples so I would like to know how to do it with any amount of points and how to draw any line that connects points on a circle. I think that tikz package would be useful. I know how to draw circle, points and lines using tikz, but i cant get my head around about how to connect this things.

1

2 Answers 2

4

A possibility is to do a marco that draws the set (the circle) and the points, and that names each one. Then all you have to do is connect the desired points. It could be something like this:

\documentclass[border=2mm]{standalone}
\usepackage{tikz}

% Macro
\def\r{2} % raduis
\newcommand{\myset}[4] % name, position x, position y, number of points
{%
  \begin{scope}[shift={(#2,#3)}]
    \coordinate (#1) at (0,0) {};
    \draw (0,0) circle (\r);
    \pgfmathsetmacro\angle{360/#4}
    \foreach\i in {1,...,#4}
    {%
      \pgfmathsetmacro\thisangle{-\angle*(\i-1)+90-0.5*\angle}
      \coordinate (#1-\i) at (\thisangle:\r);
      \node at (\thisangle:1.1*\r) {$\i$};
      \fill (\thisangle:\r) circle (1pt);  
    }
\end{scope}
}

\begin{document}
\begin{tikzpicture}[line join=round, line cap=round]
  % A set with 8 points
  \myset{S1}{0}{0}{8}
  \draw (S1-1) -- (S1-3) -- (S1-8) -- cycle;
  \draw (S1-5) -- (S1-7);
  % Anotehr set with 10 points
  \myset{S2}{5}{0}{10}
  \draw (S2-2) -- (S2-5) -- (S2-7) -- (S2-9) -- cycle;
  \draw (S2-6) -- (S2-8);
\end{tikzpicture}
\end{document}

enter image description here

0

I propose this short code based on the pst-poly pstricks package:

\documentclass[x11names, border = 3pt]{standalone}%
\usepackage{fourier}
\usepackage{pst-poly}
\usepackage{multido}

\begin{document}

\begin{pspicture}(-2,-2)(2,2)%
\psset{unit = 1.25}
\pscircle(0,0){1}
    \providecommand{\PstPolygonNode}{%
        \psdots[dotstyle=o, dotsize=2pt,fillstyle = solid, fillcolor=IndianRed3](1;\INode)}
    \psset{ linewidth = 0.6pt}
    \rput(0,0){\PstOctogon[linestyle = none, PolyName=A, PolyRotation=45]}
    \psset{nodesep=1pt, linecolor=LightSteelBlue3}
    \ncline{A2}{A3}\ncline{A3}{A8}\ncline{A8}{A2}
    \ncline{A4}{A6}
    \psset{labelsep=3pt}
\multido{\i=3+1,\Id=8 + -1, \na=112.5+45}{6}{\nput{\na}{A\i}{\scriptsize\Id}}
\nput{22.5}{A1}{\scriptsize2}\nput{67.5}{A2}{\scriptsize1}
\end{pspicture}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .