一切进展顺利,但后来我不知道如何放置单词和点。我尝试使用节点,但它产生了巨大的东西,我无法让它变小。请告诉我,谢谢。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,calc}
\begin{document}
\begin{tikzpicture}[node distance=5mm,box/.style = {draw, very thick, minimum width=7em,minimum height=14em}]
\node (n1) [box,path picture={\coordinate (A) at (0.75,-1.75);
\draw[dotted] (-1.5,-1.75)--(1.5,-1.75);
\node at (A) [circle,fill,inner sep=0.0005pt]{};
}]{};
\node (n2) [box,right=of n1,path picture={\draw[dotted] (-1.5,-1.75)--(1.5,-1.75);}]{};
\node (n3) [box,right=of n2,path picture={\draw[dotted] (-1.5,-1.75)--(1.5,-1.75);}]{};
\node (n4) [box,right=of n3,path picture={\draw[dotted] (-1.5,-1.75)--(1.5,-1.75);}]{};
\end{tikzpicture}
答案1
如果将一个节点放在path picture
另一个节点的 中,则会出现键继承问题,类似于嵌套tikzpicture
s 时发生的情况。在我看来,更简洁的方法是使用pic
s。您可以通过 pgf 键控制参数,这些参数可以随时设置。此外,值得设置局部坐标系,其中框的左下角为(0,0)
,右上角为(1,1)
。然后放置这些点会更加直观。可以使用 将它们偷运到pic
s中。最后,可以使用 完成 sextra/.code={...}
的相对定位。pic
\matrix
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[bullet/.style={circle,inner
sep=1.5pt,fill=black},wullet/.style={circle,inner
sep=1.2pt,fill=white},font=\sffamily,
pics/container/.style={code={
\tikzset{container/.cd,#1}%
\def\pv##1{\pgfkeysvalueof{/tikz/container/##1}}%
\begin{scope}[shift={(-\pv{w}/2,-\pv{h}/2)},x=\pv{w},y=\pv{h}]
\fill[gray!40] (0,0) rectangle (1,\pv{p});
\draw[densely dotted] (0,\pv{l}) -- (1,\pv{l});
\draw[very thick] (0,0)
rectangle (1,1);
\path (0.5,1) node[below]{\pv{text}};
\pgfkeys{/tikz/container/extra}
\end{scope}
}},container/.cd,w/.initial=7em,h/.initial=14em,p/.initial=0,l/.initial=0.12,
text/.initial={},extra/.code={}]
\matrix[column sep=1em] (mat) {
\pic{container={p=0.1,text=initial,extra/.code={
\path (1/4,\pv{l}) node[bullet=black](b1){} (3/4,\pv{l}) node[bullet](b2){};
}}};
& \pic{container={p=0.2,text=10 minutes,extra/.code={
\path (1/4,0.1) node[bullet=black](b3){} (3/4,0.14) node[bullet](b4){};
}}};
& \pic{container={p=0.65,text=30 minutes,extra/.code={
\path (1/4,0.2) node[wullet](b5){} (1/4,0.21) node[bullet](b6){}
(3/4,0.24) node[bullet](b7){} (3/4,0.22) node[wullet](b8){};
}}};
& \pic{container={p=0.85,text=final,extra/.code={
\path (1/4,0.3) node[wullet](b9){} (1/4,0.35) node[bullet](b10){}
(3/4,0.7) node[bullet](b11){} (3/4,0.6) node[wullet](b12){};
}}};
\\};
\path[nodes={align=left,font=\tiny}]
(mat.south west) node[anchor=south east,xshift=-1em] (p1) {Mobile\\ Phase}
node[above=1em of p1] (p2){Sample\\ Mixture};
\path[nodes={align=right,font=\tiny}]
(mat.south east) node[anchor=south west,xshift=1em,yshift=3em]
(p3) {Some\\ long\\ text}
node[above=1em of p3] (p4){Some\\ long\\ text};
\draw (p1) -- (b1) (p2) -- (b2) (p3) -- (b12) (p4) -- (b11);
\end{tikzpicture}
\end{document}