
受到下圖的啟發,我嘗試用 tikz 複製它。我想修改一下一些細節:
- 彩色背景的邊緣應該是均勻的。
- 我不想要氨基酸之間的鍵,我更喜歡它們分開
這是我的第一次嘗試:
\documentclass{standalone}%
\usepackage[ngerman]{babel}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri}
\usepackage{chemfig,xstring}
\begin{document}
\setatomsep{2.5em}
\setcrambond{2pt}{}{}
\begin{tikzpicture}[
point/.style={circle,draw=none,minimum size=#1},
point/.default=0pt % default Wert für minimum size bei point]
\foreach \anfang/\ende/\farbe in { 25/100/green!60,104/170/orange!60,174 /254/red!60, 258/314/yellow!60, 318/381/blue!60}
\draw[fill=\farbe,draw=none] (0,0) -- (\anfang:12cm) arc (\anfang:\ende:12cm);
\draw[fill=white,draw=none] (0,0) circle (6cm);
% mit count=\i werden die Kreise nummeriert
% der zugehörige Winkel wird mit evaluate aus dieser Nummer berechnet
% insgesamt werden (bis zu) 20 Kreise auf 360 Grad gleichmäßig verteilt
\foreach[count=\i,evaluate=\i as \angle using (\i-1)*360/20] \text in {%
1,2,3,4,\begin{tiny}\schemestart \chemnameinit{}\chemname{\chemfig{C(=[3]O)(-[1]OH)(-[6]CH_2(-[6]CH(-[5]NH_2)(-[7]C(=[6]O)(-[1]OH))))}}{Asparaginsäure\\Asp\\D} \schemestop\end{tiny},\begin{tiny}\schemestart \chemnameinit{} \chemname{\chemfig{CH(-[3]NH_2)(-[1]C(=[2]OH)(-[7]OH))(-[6]CH_2(-[6]C(=[5]O)(-[7]NH_2)))}}{Asparagin\\Asn\\N}\schemestop\end{tiny},7,8,9,10,11,12,13,14,15,16,17,18,19,20% Beschriftung der Kreise
}
\node[point=2.2em] (node\i) at (\angle:9) {\text};
\end{tikzpicture}
\end{document}
我在另一個 TeX 檔案中編寫了氨基酸的結構,並且通常使用該\input
命令。對於 MWE 來說,兩個胺基酸就足夠了。
如何旋轉節點/胺基酸,使它們指向內圓的中心?
任何替代解決方案也是受歡迎的。
非常抱歉,但我無法評論我自己的問題,因此我在此處添加資訊。
@Alenanno 非常感謝您非常有幫助的回答。
我不想要相同的圖形。我實際上很喜歡到目前為止所得到的:彩色圓圈中的所有結構公式與中心的距離幾乎相同。
下一步將是外部描述(小、極性(親水)等)。如果可以的話,如果我能做到的話,我希望描述位於彩色圓圈內緣的結構式下方。
能告訴我如何解決單節點問題嗎?
您定義 \aminoacid 指令的目的是什麼? - 我無法從 MWE 獲得它
問候
@Alenanno:這正是我想要的!多謝!在已接受按鈕旁邊是否有標記您的答案的功能?
答案1
您可以新增rotate=\angle-90
到由 foreach 列印的節點。
編輯:由於您不希望 OP 中出現該圖像,因此這是您的固定版本。請注意,您可以繪製彩色弧線,而無需“切割”中間的白色圓圈。我已經解決了這個問題。我認為描述正如您所希望的那樣(德語字符應該是固定的)。如果您不希望它們著色,請\color{\farbe}
從程式碼中刪除該行。
編輯2:請參閱下面的不同版本。
輸出
程式碼
\documentclass[margin=10pt]{standalone}%
\usepackage[ngerman]{babel}
\usepackage{tikz}
\usetikzlibrary{calc, arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri, intersections, decorations.text}
\usepackage{pgfmath}
\usepackage{chemfig,xstring}
\tikzset{
point/.style={minimum size=#1},
point/.default=0pt,
bent text/.style={postaction={
decorate,
decoration={
text along path,
reverse path=true,
text align/align=center,
text={| \Large\bfseries\color{\farbe}|#1}
}
}
}
}
\def\colorlist{{"green!60", "orange!60", "red!60", "yellow!60", "blue!60"}}
\begin{document}
\setatomsep{2.5em}
\setcrambond{2pt}{}{}
\begin{tikzpicture}\tiny
\foreach \anfang/\ende/\descr [count=\ix starting from 0] in {%
25/100/{klein polar (hydrophil)},
104/170/{groß, polar (hydrophil)},
174/254/{mittiere Polarität},
258/314/{groß unpolar},
318/381/{klein, unpolar}}{
\pgfmathsetmacro\farbe{\colorlist[\ix]}
\fill[\farbe] (\anfang:6cm) -- (\anfang:12cm) arc (\anfang:\ende:12cm) -- (\ende:6cm) arc (\ende:\anfang:6cm);
\path[bent text={\descr}] (\anfang:5cm) arc (\anfang:\ende:5cm);
}
% mit count=\i werden die Kreise nummeriert
% der zugehörige Winkel wird mit evaluate aus dieser Nummer berechnet
% insgesamt werden (bis zu) 20 Kreise auf 360 Grad gleichmäßig verteilt
\foreach [count=\i, evaluate=\i as \angle using int((\i-1)*360/20), evaluate=\i as \midangle using int((\i-1.5)*360/20), remember=\midangle as \lastmid (initially -27)] \text in {%
1,2,3,4,
\schemestart \chemnameinit{}\chemname{\chemfig{C(=[3]O)(-[1]OH)(-[6]CH_2(-[6]CH(-[5]NH_2)(-[7]C(=[6]O)(-[1]OH))))}}{Asparaginsäure\\Asp\\D} \schemestop,
\schemestart \chemnameinit{} \chemname{\chemfig{CH(-[3]NH_2)(-[1]C(=[2]OH)(-[7]OH))(-[6]CH_2(-[6]C(=[5]O)(-[7]NH_2)))}}{Asparagin\\Asn\\N}\schemestop
,7,8,9,10,11,12,13,14,15,16,17,18,19,20% Beschriftung der Kreise
}{
\node[point=2.2em, rotate=\angle-90] (node\i) at (\angle:9) {\text};
}
\end{tikzpicture}
\end{document}
匹配OP
這是適合您圖像中的另一個版本。
輸出
程式碼
\documentclass[margin=10pt]{standalone}%
\usepackage[ngerman]{babel}
\usepackage{tikz}
\usetikzlibrary{calc, arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri, intersections, decorations.text}
\usepackage{pgfmath}
\usepackage{chemfig,xstring}
\definecolor{xlime}{RGB}{228,246,13}
\definecolor{xpink}{RGB}{245,109,175}
\definecolor{xorange}{RGB}{232,117,53}
\definecolor{xgreen}{RGB}{151,184,43}
\definecolor{xblue}{RGB}{144,181,236}
\tikzset{
point/.style={minimum size=#1},
point/.default=0pt,
bent text/.style={postaction={
decorate,
decoration={
text along path,
reverse path=true,
text align/align=center,
text={| \Large\bfseries\color{\farbe}|#1}
}
}
}
}
\newcommand\aminoacids[4][black]{
\node[point=2.2em, minimum width=5cm,rotate=\angle-90, inner sep=2mm] (node#2) at (#3) {#4};
\path[green, name path=around] (node#2.north west) -- (node#2.north east) -- (node#2.south east) -- (node#2.south west) -- cycle;
\path[name path={tris#2}] (\midangle:12cm) -- (0,0) -- (\lastmid:12cm) -- cycle;
\path[name intersections={of={tris#2} and around, name=i, total=\t}];
\begin{scope}[on background layer]
\filldraw[draw=black, fill=#1] (i-1) -- (i-2) -- (i-4) -- (i-3) -- cycle;
\end{scope}
}
\def\colorlist{{"xgreen", "xorange", "xpink", "xlime", "xblue"}}
\begin{document}
\setatomsep{2.5em}
\setcrambond{2pt}{}{}
\begin{tikzpicture}\tiny
\foreach \anfang/\ende/\descr [count=\ix starting from 0] in {%
25/100/{klein polar (hydrophil)},
104/170/{groß, polar (hydrophil)},
174/254/{mittiere Polarität},
258/314/{groß unpolar},
318/381/{klein, unpolar}}{%
\pgfmathsetmacro\farbe{\colorlist[\ix]}
\path[bent text={\descr}] (\anfang:5cm) arc (\anfang:\ende:5cm);
}
\foreach [count=\i,
evaluate=\i as \angle using int((\i-1)*360/20),
evaluate=\i as \midangle using int((\i-1.5)*360/20),
evaluate=\midangle as \lastmid using int((\i-.5)*360/20)
]
\text/\colr in {%
1/0,2/0,3/0,4/0,
\schemestart \chemnameinit{}\chemname{\chemfig{C(=[3]O)(-[1]OH)(-[6]CH_2(-[6]CH(-[5]NH_2)(-[7]C(=[6]O)(-[1] OH))))}}{Asparaginsäure\\Asp\\D} \schemestop/0,
\schemestart \chemnameinit{} \chemname{\chemfig{CH(-[3]NH_2)(-[1]C(=[2]OH)(-[7]OH))(-[6]CH_2(-[6]C(=[5]O)(-[7] NH_2)))}}{Asparagin\\Asn\\N}\schemestop/0
,7/1,8/1,9/1,10/2,11/2,12/2,13/3,14/3,15/3,16/3,17/4,18/4,19/4,20/4% Beschriftung der Kreise
}{
\pgfmathsetmacro\farbe{\colorlist[\colr]}
\aminoacids[\farbe]{\i}{\angle:9}{\text}
}
\end{tikzpicture}
\end{document}