我正在尝试创建 DNA 比对图。以下是我所拥有的:
\definecolor{color1}{RGB}{255,183,236}
\definecolor{color2}{RGB}{255,249,158}
\begin{center}
\begin{tikzpicture}
\node (read) [rectangle,draw,fill=color1] {TTTCAGATTT};
\node (refread) at (1,3) [rectangle,draw,fill=color1] {TTTCAGATTT};
\node at (refread.west) [rectangle,draw,fill=color2,anchor=east] {ACCAGG};
\node at (refread.east) [rectangle,draw,fill=color2,anchor=west] {AAA};
\draw[->]{(read) -- (refread)};
\end{tikzpicture}
\end{center}
我怎样才能使顶部的东西看起来像一个序列,其各个部分突出显示,即更像
答案1
首先在顶部画出不带框架的方框,然后在它们周围画一个方框:
\begin{tikzpicture}
\node (read) [rectangle,draw,fill=color1] {TTTCAGATTT};
\node (refread) at (1,3) [rectangle,fill=color1,inner xsep=0pt,line width=0] {TTTCAGATTT};
\node (first) at (refread.west) [rectangle,fill=color2,anchor=east,inner xsep=0pt,,line width=0] {\,ACCAGG};
\node (last) at (refread.east) [rectangle,fill=color2,anchor=west,inner xsep=0pt,line width=0] {AAA\,};
\draw (first.south west) rectangle (last.north east);
\draw[->]{(read) -- (refread)};
\end{tikzpicture}
编辑:修改以解决白边问题。框高度没有改变;那可能只是我的 pdf 查看器(我从中截取了屏幕截图)造成的问题。
答案2
除了迈克尔的回答之外:
盒子高度仍然不均匀;我用\vphantom
如下方法修复了它:
\node at (refread.east) [...] {\vphantom{ACTG}AAA\,};