# Circular sequence diagram (tikz?)

Apologies in advance for the slightly-crappy camera phone picture:

I'd like to include some figures like this in something I'm working on. I've just started learning tikz, which seems like it could be used to do something like this, but I'm not quite dextrous enough just yet.

The included picture has 16 cells, but I have another figure with 8 cells and a less important one with 27 cells, so if this can be done generally to make doing those easy as well, that'd be great.

-
some related posts: question search for ring chart –  cmhughes Dec 6 '12 at 4:20
It would be nice to have certain cells filled with color. –  Uwe Ziegenhagen Dec 6 '12 at 4:21
You can check the examples of chains and foreach commands in the manual for a few examples similar to this one. Also you can check this one for the repetition task. tex.stackexchange.com/questions/42261/… –  percusse Dec 6 '12 at 4:23

The CircularSequence macro below takes three paramaters:

• the sequence to be applied

which should be able to create this image with any desired number of elements. Below are examples with 8 and 16 elements:

## Code:

\documentclass{article}
\usepackage{tikz}
\usepackage{xstring}

% http://tex.stackexchange.com/questions/21559/macro-to-access-a-specific-member-of-a-list/21560#21560
\newcommand*\GetListMember[2]{\StrBetween[#2,\number\numexpr#2+1]{,#1,},,\par}%

\newcommand*{\CircularSequence}[3]{%
% #1 = outer circle radius
% #2 = inner circle radius
% #3 = seqeunce
\StrCount{#3}{,}[\NumberOfElements]
\pgfmathsetmacro{\AngleSep}{360/(\NumberOfElements+1)}
\draw [red,  ultra thick] circle (#2);
\draw [blue, ultra thick] circle (#1);
\foreach [count = \Count] \Angle in {0,\AngleSep,..., 360} {%
\draw [gray, ultra thick] (\Angle:#2) -- (\Angle:#1);
\pgfmathsetmacro{\MidPoint}{\Angle+\AngleSep/2}
}%
}%
\begin{document}
\begin{tikzpicture}
\CircularSequence{3.0cm}{2.cm}{1,2,3,4,5,6,7,8}

\begin{scope}[xshift=7.0cm]
\CircularSequence{2.5cm}{1.5cm}{1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8}
\end{scope}
\end{tikzpicture}
\end{document}

-
Thanks! (and fast) Sadly, this doesn't compile for me. The errors are: ./circular-sequence-test.tex:26: Missing control sequence inserted. <inserted text> \inaccessiblel.26 ...ularSequence{3.0cm}{2.cm}{1,2,3,4,5,6,7,8} ? ./circular-sequence-test.tex:26: Undefined control sequence. <argument> \Angle :2.cm l.26 ...ularSequence{3.0cm}{2.cm}{1,2,3,4,5,6,7,8} ... Replacing 2.cm with 2.0cm does not help. –  Harold Dec 6 '12 at 4:57
I suspect that you are on an older release. Unless there is a good reason to stay on that you should probably to upgrade to TexLive 2012. –  Peter Grill Dec 6 '12 at 4:59
Indeed I am. I shall upgrade. –  Harold Dec 6 '12 at 5:08
–  cmhughes Dec 6 '12 at 5:08
@Harold: My crystal ball says that you are on a 2009 release. :-) And if so, you should just install TeXLive2012 directly. –  Peter Grill Dec 6 '12 at 5:08
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8037248253822327, "perplexity": 4416.5254597279845}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-11/segments/1424936463475.57/warc/CC-MAIN-20150226074103-00002-ip-10-28-5-156.ec2.internal.warc.gz"}