Inspired by this question and an answer by @Schrödinger's cat, how to draw a table of clocks on a plane in an effective way?
Asked
Active
Viewed 314 times
1 Answers
10
This is just a nested loop.
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \X in {1,...,5}
{\foreach \Y in {1,2,3}
{\draw (\X,\Y) circle[radius=4mm]
(\X,\Y) -- ++(180-45*\X:0.4);
}}
\end{tikzpicture}
\end{document}
But one can do better using some existing post.
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d,decorations.markings}
\tikzset{Annie/.cd,
hour/.initial=0,
hour arm/.style={thick,shorten >=1mm,red},
clock/.style={semithick,fill=white},
clock radius/.initial=5mm}
\begin{document}
\tdplotsetmaincoords{60}{20}
\begin{tikzpicture}[tdplot_main_coords,pics/clock/.style={code={
\tikzset{Annie/.cd,#1}
\draw[Annie/clock] (0,0)
circle[radius=\pgfkeysvalueof{/tikz/Annie/clock radius}];
\draw[Annie/hour arm] (0,0) --
(90-30*\pgfkeysvalueof{/tikz/Annie/hour}:\pgfkeysvalueof{/tikz/Annie/clock radius});
}},ruler/.style={postaction={decorate,decoration={markings,
mark=between positions 0 and 1 step 5pt with {\draw (0,-#1/2) -- (0,#1/2);}}}}]
\begin{scope}[canvas is xz plane at y=0,transform shape]
\draw[double=cyan,double distance=4pt,ruler=4pt] (-4,-2.4) grid[step=pi/2] (4,4);
\path foreach \X in {-2,...,2}
{foreach \Y in {-1,...,2}
{ (\X*pi/2,\Y*pi/2) pic{clock={hour=\X*3/2}}}};
\end{scope}
\end{tikzpicture}
\end{document}
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d,decorations.markings}
\tikzset{Annie/.cd,
hour/.initial=0,
hour arm/.style={thick,shorten >=1mm,red},
clock/.style={semithick,fill=white},
clock radius/.initial=5mm}
\begin{document}
\tdplotsetmaincoords{60}{00}
\begin{tikzpicture}[tdplot_main_coords,pics/clock/.style={code={
\tikzset{Annie/.cd,#1}
\draw[Annie/clock] (0,0)
circle[radius=\pgfkeysvalueof{/tikz/Annie/clock radius}];
\draw[Annie/hour arm] (0,0) --
(90-30*\pgfkeysvalueof{/tikz/Annie/hour}:\pgfkeysvalueof{/tikz/Annie/clock radius});
}},ruler/.style={postaction={decorate,decoration={markings,
mark=between positions 0 and 1 step 5pt with {\draw (0,-#1/2) -- (0,#1/2);}}}}]
\begin{scope}[canvas is xz plane at y=0,transform shape]
\draw[double=cyan,double distance=4pt,ruler=4pt] (-4,-2.4) grid[step=pi/2] (6,4);
\path foreach \X in {-2,...,3}
{foreach \Y in {-1,...,2}
{ (\X*pi/2,\Y*pi/2) pic{clock={hour=\X*3/2}}}};
\end{scope}
\end{tikzpicture}
\end{document}
-
Nice for the last figure. how do we remove the blue rulers or rails? – annie marie cœur Sep 22 '19 at 02:31
-
@annieheart I changed it. (Had to change a couple of pgf keys.) If you want an "untitled" view, use e.g.
\tdplotsetmaincoords{60}{0}. – Sep 22 '19 at 02:41



just-do-it-for-mequestion. And, if you find the answers to your past questions useful, consider accepting then before asking a new one. – Raaja_is_at_topanswers.xyz Sep 22 '19 at 10:25\documentclass{}...\begin{document}etc. As it is, most of our users will be very reluctant to touch your question, and you are left to the mercy of our procrastination team who are very few in number and very picky about selecting questions. You can improve your question by adding a minimal working example (MWE) that more users can copy/paste onto their systems to work on. If no hero takes the challenge we might have to close your question. – BambOo Sep 22 '19 at 10:54