# differently colored polygons?

I want to create 6 hexagons side by side, each having a different number of edges dashed instead of normal. How is it possible?
The code I currently use to create a single hexagon is:

\foreach \n in {1,2,...,6} {
\node at (\n*2.5-4,1)[above left] {\n$.$} ;
\draw [xshift=\n*2.5cm-3cm] (0:1cm) \foreach \x in {1,2,...,6} {
-- (\x*60:1cm)} --cycle (90:1cm);
}

I don't mind creating each hexagon individually if there's no simple way to create them in a loop, but I don't even know how to do that.

edit: Clarifications: What I want to achieve is basically a list of hexagons, each with a different "order" of edges dashed (That is, all the possible variations of dashed edges such that you can't get from one to the other by rotating the hexagon). I though that's a bit too broad of a questiong so I asked about the coloring of one hexagon with a certain dashed pattern, but I guess I wasn't clear enough (sorry for that, English is not my mother tounge so stuff tend to get messy).

I'm using TeX through Lyx and don't really know how to use it very well, so I don't know how to post an MWE, sorry :(.

• I think you should post a full MWE, not just a snippet. It is hard to understand what you really want: what exactly is 'side by side' (i.e. do they have common side or are they entirely separate hexagons)? what do you mean by 'a different number of edges dashed'? is there a pattern to follow? etc. Nov 17, 2012 at 18:14

If you really want to meet the constraint

all the possible variations of dashed edges such that you can't get from one to the other by rotating the hexagon

then an alternate solution is required.

The number of dashed edges is increased for each row, and the ones that are equivalent by rotational symmetry have an opacity applied to them:

## Code:

\documentclass{article}

\usepackage{tikz}
\tikzset{Dashed/.style={dashed, red}}
\tikzset{Duplicate/.style={opacity=0.5, thin, gray}}
\newcommand{\Hexagon}[8][]{%
%\node at (#1*2.5-4,1)[above left] {$#1.$};
\begin{scope}[xshift=#2*2.5cm-3cm,#1] %,rotate=#1*60
\draw[solid, #3] (   0:1cm) -- (1*60:1cm);
\draw[solid, #4] (1*60:1cm) -- (2*60:1cm);
\draw[solid, #5] (2*60:1cm) -- (3*60:1cm);
\draw[solid, #6] (3*60:1cm) -- (4*60:1cm);
\draw[solid, #7] (4*60:1cm) -- (5*60:1cm);
\draw[solid, #8] (5*60:1cm) -- (6*60:1cm);
\end{scope}
}%
\begin{document}
\begin{tikzpicture}[ultra thick, blue]
\Hexagon           {1}{Dashed}{}{}{}{}{}
\Hexagon[Duplicate]{2}{}{Dashed}{}{}{}{}
\Hexagon[Duplicate]{3}{}{}{Dashed}{}{}{}
\Hexagon[Duplicate]{4}{}{}{}{Dashed}{}{}
\Hexagon[Duplicate]{5}{}{}{}{}{Dashed}{}
\Hexagon[Duplicate]{6}{}{}{}{}{}{Dashed}
\begin{scope}[yshift=-3cm]
\Hexagon           {1}{Dashed}{Dashed}{}{}{}{}
\Hexagon           {2}{Dashed}{}{Dashed}{}{}{}
\Hexagon           {3}{Dashed}{}{}{Dashed}{}{}
\Hexagon[Duplicate]{4}{Dashed}{}{}{}{Dashed}{}
\Hexagon[Duplicate]{5}{Dashed}{}{}{}{}{Dashed}
\end{scope}
\begin{scope}[yshift=-6cm]
\Hexagon           {1}{Dashed}{Dashed}{Dashed}{}{}{}
\Hexagon           {2}{Dashed}{Dashed}{}{Dashed}{}{}
\Hexagon           {3}{Dashed}{Dashed}{}{}{Dashed}{}
\Hexagon[Duplicate]{4}{Dashed}{}{}{}{Dashed}{Dashed}
\end{scope}
\begin{scope}[yshift=-9cm]
\Hexagon{1}{Dashed}{Dashed}{Dashed}{Dashed}{}{}
\Hexagon{2}{Dashed}{Dashed}{Dashed}{}{Dashed}{}
\Hexagon{3}{Dashed}{}{Dashed}{Dashed}{}{Dashed}
\end{scope}
\begin{scope}[yshift=-12cm]
\Hexagon           {1}{Dashed}{Dashed}{Dashed}{Dashed}{Dashed}{}
\Hexagon[Duplicate]{2}{Dashed}{Dashed}{Dashed}{Dashed}{}{Dashed}
\end{scope}
\begin{scope}[yshift=-15cm]
\Hexagon{1}{Dashed}{Dashed}{Dashed}{Dashed}{Dashed}{Dashed}
\end{scope}
\end{tikzpicture}
\end{document}
• Yeah, I knew this part, that's why I only asked for a quick tikz advice in order to do it on my own. I'm already done with it. But I didn't even know the idea of creating a hexagon command like that is even possible, would definitely have saved me some work. (though not much thanks to copy paste, but would made the file A LOT neater and more readable). Nov 17, 2012 at 22:48
• Wow, this is actually quite amazing now! I have a feeling I'm really going to enjoy tikz Nov 17, 2012 at 22:56

answering your question would at least be easier if you provided us with a picture of some sort of what you want to achieve.

The following does produce 6 different hexagons:

\documentclass{article}

\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \n in {1,2,...,6}
{
\node at (\n*2.5-4,1)[above left] {\n$.$};
\begin{scope}[xshift=\n*2.5cm-3cm,rotate=\n*60]
\draw[dashed] (0:1cm) -- (60:1cm);
\draw (60:1cm) \foreach \x in {2,...,6} {-- (\x*60:1cm)};
\end{scope}
}
\end{tikzpicture}
\end{document}

Result in:

• This is exactly the answer I was looking for. The idea (well, at list the first step), is that 1 would have 1 dashed line, 2 would have 2, 3 would have 3 and so on. But that I was able to do myself. btw if I had a picture of what I want I wouldn't need to creat one with tikz... Nov 17, 2012 at 22:24
• @Nescio You could have had a sketch that you had made in some other program, e.g. Paint, or by hand on paper and had scanned/photographed. Nov 18, 2012 at 0:29