0

I am trying to draw a circle and mark some points on it as follows:

    \begin{tikzpicture}
        \draw (2,2) circle (2cm);
        \fill[black!100!] (1,0.25) circle (0.10cm);
        \fill[black!100!] (4,2) circle (0.10cm);
        \fill[black!100!] (2.4,3.97) circle (0.10cm);
        \fill[red!100!] (2,2) circle (0.10cm);
        \node at (0.5,-0.25) {$(x_1,y_1)$};
        \node at (5,2) {$(x_2,y_2)$};
        \node at (2.4,4.57) {$(x_3,y_3)$};
        \node at (2,1.5) {$(a_1,a_2)$};
    \end{tikzpicture}

Which plots this:

enter image description here

I was looking for a simpler way to label the nodes without having to manually figure out the position of every single point relative to the plotted point, when i found this post: Label a single coordinate (pgfplots). When I tried using pgf plot, I could label the points easily, but I couldn't remove the different axes and plots that showed up. Is there a cleaner way to do this?

User20354
  • 103

2 Answers2

1
  • Use of the polar coordinate system enable simple way to define circles positioning as well they labeling.
  • Instead to draw circles I suggest to use nodes, which can be easy labeling by option label:
\documentclass[tikz, margin=3mm]{standalone}

\begin{document} \begin{tikzpicture}[ dot/.style = {circle, fill=#1, minimum size=2mm, inner sep=0pt}, dot/.default = black ]
% circle \draw (0,0) circle (2cm); % nodes \node [dot=red, label=below:{$(a_1,a_2)$}] {}; \node [dot,label= 85:{$(x_3,y_3)$}] at (85:2) {}; \node [dot,label= 0:{$(x_2,y_2)$}] at ( 0:2) {}; \node [dot,label=240:{$(x_1,y_1)$}] at (240:2) {}; \end{tikzpicture} \end{document}

enter image description here

Addendum: I you like to draw lines between nodes in above diagram, than you can do this simply by named nodes and then draw line by \draw (<node name>) -- (<node name>); For example:

\documentclass[tikz, margin=3mm]{standalone}

\begin{document} \begin{tikzpicture}[ dot/.style = {circle, fill=#1, minimum size=2mm, inner sep=0pt, outer sep=0pt}, dot/.default = black ] % circle \draw (0,0) circle (2cm); % nodes \node (O) [dot=red, label=below:{$(a_1,a_2)$}] {}; \node (a) [dot,label= 85:{$(x_3,y_3)$}] at (85:2) {}; \node (b) [dot,label= 0:{$(x_2,y_2)$}] at ( 0:2) {}; \node (c)[dot,label=240:{$(x_1,y_1)$}] at (240:2) {}; % lines \draw (O) -- (b); \end{tikzpicture} \end{document}

enter image description here

Of course, you can draw line between two coordinates defined by polar coordinates. For example:

\draw (0:0) -- (0:2):

Using this in above MWE will not give the same result as is shown in above image: line will appear between center of nodes at those coordinates, meanwhile in above MWE is between nodes borders.

Zarko
  • 296,517
  • I really like this. If I want to add lines between points, it seems like using "\draw (,) -- (,)" still draws the line in rectangular coordinates. Is using polar coordinates only limited to plotting points or can one draw lines with it too? (Do you have any reference where I can read more about this? That would be helpful too) – User20354 Aug 28 '20 at 03:09
  • Nevermind. Apologies. I just understood that using ':' instead of '(,)' automatically uses polar coordinates. Thanks! – User20354 Aug 28 '20 at 03:12
0
    \begin{tikzpicture}
    \draw (2,2) circle (2cm);
    \fill[black!100!] (1,0.25) circle (0.10cm) node[below]{$(x_1,y_1)$};
    \fill[black!100!] (4,2) circle (0.10cm)node[right]{$(x_2,y_2)$};
    \fill[black!100!] (2.4,3.97) circle (0.10cm)node[above]{$(x_3,y_3)$};
    \fill[red!100!] (2,2) circle (0.10cm)node[below] {$(a_1,a_2)$};
    \end{tikzpicture} 
js bibra
  • 21,280