Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Labelling a tikz picture in Latex

\begin{tikzpicture}
\filldraw[color=black!60, fill=white!5, ultra thick](-1,0) circle (0.8);
\filldraw[color=black!60, fill=white!5, ultra thick](5,0) circle (0.8);
\draw[black, ultra thick] (-1,0) -- (5,0);
\end{tikzpicture}

This code creates a picture with two circles and a line joining their centres. I need to label the left circle as Left Circle and the right one as Right Circle. Both labels have to be at the top of the circles, NOT below them.

Can I please have some help with this?

like image 863
user14854948 Avatar asked Sep 19 '25 02:09

user14854948


1 Answers

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

\coordinate (A) at (-1,0);
\coordinate (B) at (5,0);

\filldraw[color=black!60, fill=white!5, ultra thick] (A) circle (0.8) node[label={[yshift=2em,black]above:left circle}] {};
\filldraw[color=black!60, fill=white!5, ultra thick] (B) circle (0.8) node[label={[yshift=2em,black]above:right circle}] {};
\draw[black, ultra thick] (A) -- (B);
\end{tikzpicture}

\end{document}

enter image description here

like image 191
samcarter_is_at_topanswers.xyz Avatar answered Sep 22 '25 08:09

samcarter_is_at_topanswers.xyz