答案1
这是代码这个答案经过修改,使得股线从上向下而不是从左向右。
\documentclass[border=3pt]{standalone}
\usepackage{tikz}
\usepackage{xstring,calc}
\usetikzlibrary{calc,positioning}
\newlength{\NodeSize}
\tikzset{DNA Style/.style={minimum size=0.5cm, draw=gray, line width=1pt, inner sep = 2pt}}{}
\newcounter{ColumnCounter}% Prefix for node labels
\newlength{\CurrentXPos}
\newcommand*{\PreviousNode}{}%
\newcommand*{\DNASequence}[2][Mark]{%
% https://tex.stackexchange.com/questions/12091/tikz-foreach-loop-with-macro-defined-list
\def\Sequence{#2}%
\def\PreviousNode{}%
\foreach [count=\xi] \Label/\Color in \Sequence {%
\IfStrEq{\Color}{}{\def\Color{white}}{}
\edef\NodeName{#1-\arabic{ColumnCounter}}
\IfStrEq{\PreviousNode}{}{%
\node [DNA Style, fill=\Color, anchor=south west] (\NodeName) {\Label};
\xdef\PreviousNode{\NodeName}%
}{
\node [DNA Style, fill=\Color, anchor=north west, yshift=\pgflinewidth] at (\PreviousNode.south west)(\NodeName) {\Label};
\xdef\PreviousNode{\NodeName}%
}
\stepcounter{ColumnCounter}
}
}%
\begin{document}
\tikzset{note/.style={circle,draw,align=left}}
\begin{tikzpicture}[>=stealth]
\DNASequence[cell]{ABCC/magenta!20,,,XYZ/violet!30,,ABC/green, G/blue!20,, G/cyan!30,,C/olive};
\node[note] (note1) at ($(cell-3)+(2,0)$) {Observe\\this};
\node[note] (note2) [below=of note1] {And this,\\too!};
\draw[->] (note1) -- (cell-3);
\draw[->] (note2) -- (cell-7);
\end{tikzpicture}
\end{document}