你好,我有一个 DNA 序列,我想画一个图形来表示树的高度(大多数原因共同祖先的时间)可以改变。这是一项相当困难的工作,我不知道如何画“树”。我已尽力展示我的目标,我非常希望得到一些提示、想法或类似问题的链接。这是我的 TikZ 代码。
\documentclass[report, 11pt ]{memoir}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{automata,chains}
\usetikzlibrary{trees}
\usepackage{tikz-qtree}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{positioning, arrows, automata, fit, shapes}
\usetikzlibrary{shapes.gates.logic.US,trees,positioning,arrows}
\tikzset{
pics/adn/.style args={#1 and #2 style #3}{
code={
\node[draw, fill=#1, inner sep=0pt, circle, minimum size=2mm] at (-.3,0) (A) {};
\node[draw, fill=#2, inner sep=0pt, circle, minimum size=2mm] at ( .3,0) (B) {};
\draw[#3, -, shorten >=0pt, shorten <=0pt] (A) -- (B);
\node[ellipse,draw, fit=(A) (B), inner sep=1mm] {};
}
}}
\begin{document}
\scalebox{2}{
\begin{tikzpicture}[->,>=stealth', shorten >=1pt, node distance=.5cm, ball/.style={draw, circle, minimum size=3mm, inner sep=0pt, fill=#1}]
\node[draw=none,fill=none] (0) {C};
\node[draw=none,fill=none, below of = 0] (1) {C};
\node[draw=none,fill=none, right of = 0] (2) {G};
\node[draw=none,fill=none, below of = 2] (3) {G};
\node[draw=none,fill=none, right of = 2] (4) {T};
\node[draw=none,fill=none, below of = 4] (5) {A};
\node[draw=none,fill=none, right of = 4] (6) {A};
\node[draw=none,fill=none, below of = 6] (7) {T};
\node[draw=none,fill=none, right of = 6] (8) {T};
\node[draw=none,fill=none, below of = 8] (9) {T};
\node[draw=none,fill=none, right of = 8] (10) {T};
\node[draw=none,fill=none, below of = 10] (11) {A};
\node[draw=none,fill=none, right of = 10] (12) {$\ldots$};
\node[draw=none,fill=none, below of = 12] (13) {$\ldots$};
\node[draw=none,fill=none, right of = 12] (14) {A};
\node[draw=none,fill=none, below of = 14] (15) {A};
\end{tikzpicture}
}
\end{document}
这就是我的目标:
答案1
我使用text effects long path
来排版序列并命名节点(我猜这有点小题大做),“树”的排版具有随机高度并且有点粗糙:
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{decorations.text,calc}
\tikzset{DNA sequence/.style={decoration={
text effects along path, text={#1},
text effects/.cd,
path from text, character count=\c,
character widths={minimum width=1.5ex},
characters={inner xsep=0, name=base-\c}
}, decorate}}
\begin{document}
\begin{tikzpicture}
\path [name prefix=top-, DNA sequence={CGTATT\ldots A}] (0,0);
\path [name prefix=bottom-, DNA sequence={CGATTA\ldots A}] (0,-.5);
\foreach \i in {1,...,6,8}
\draw [thick, blue!50!cyan] (top-base-\i.north west) |-
($(0,.25+rnd)+(top-base-\i.north)$)
-- ++(0,0.25) ++(0,-0.25) -| (top-base-\i.north east);
\end{tikzpicture}
\end{document}