我正在尝试使用 TikZ 叠加层来详细绘制我的图。我当前的代码是:
\documentclass{article}
\usepackage{tikz}
\usepackage{commath}
\begin{document}
\begin{figure*} \centering
\begin{tikzpicture}[
every node/.style={anchor=south east,inner sep=0pt},
x=9.5mm, y=5.1mm,
]
\node (fig1) at (0,0)
{\includegraphics[scale=0.15]{Plots/untitled.36.png}};
\draw[line width=0.5mm, blue] (-82mm, 45mm) -- (-15mm, 45mm);
\node (fig2) at (5,5)
{\includegraphics[scale=0.085]{Plots/untitled.35.png}};
\end{tikzpicture}
\caption{Using Tikz Overlay}
\end{figure*}
\end{document}
不过,我想详细说明一下我的数据:
请注意,我还想拥有一个点线或虚线线(左图的水平线)作为剖面线。
我感谢您的帮助。
答案1
恕我直言,你的图片很简单,可以直接用 Ti 绘制钾Z. 这样您就可以避免进行微调来调整位置、比例、匹配颜色等……
例如,使用此代码:
\documentclass[border=2mm,tikz]{standalone}
% colors
\definecolor{my green} {HTML}{255B37}
\definecolor{my gray} {HTML}{4D4D4D}
\definecolor{my magenta}{HTML}{CF23E9}
\definecolor{my cyan} {HTML}{24B2A2}
% styles
\tikzset{my node/.style={circle,draw,inner sep=0mm,minimum size=4mm}}
\begin{document}\sffamily
\begin{tikzpicture}[line width=0.2mm,scale=1.5]
% left figure
\fill[my green] (-2.05,-1.33) rectangle (2.05,-0.97);
\fill (-2.05,-0.97) arc (180:0:2.05cm and 0.23cm);
\fill[white] (-2.05,-0.97) to[out=0 ,in=270,looseness=1.2] (-0.98,-0.12) --
(0.98,-0.12) to[out=270,in=180,looseness=1.2] (2.05,-0.97);
\fill[my gray] (-0.98,-0.12) rectangle (0.98,1.34);
\fill[my cyan] (-0.28,-0.12) rectangle (0.28,1.34);
\foreach\i in{-1,1}
{
\begin{scope}[x=\i cm]
\draw (-2.04,-0.96) to[out=90-90*\i,in=270,looseness=1.2] (-0.97,-0.12);
\fill[my magenta] (-0.93,1.34) -- (-0.93,-0.12) -- (-0.8,-0.5) --
(-0.67,-0.12) -- (-0.67,1.34) -- cycle;
\end{scope}
}
% right figure (cross section)
\begin{scope}[shift={(4,0.61)}]
\fill[my gray] (0,0) circle (0.98);
\fill[my cyan] (0,0) circle (0.28);
\foreach[count=\j]\i in{0,30,...,330}
\fill[my magenta] (\i:0.8) circle (0.13) node [inner sep=0](C\j) {};
\end{scope}
% labels
\draw[blue,dotted] (-2.1,0.61) node [black,above] {cross} node [black,below] {section} -- (2.1,0.61);
\node at (4,2) {cross section};
\node[my node] (a) at (1.85, 2) {\strut a};
\node[my node] (b) at (1.85, 0.15) {\strut b};
\node[my node] (c) at (1.85,-0.5) {\strut c};
\node[my node] (d) at (1.85,-1.15) {\strut d};
\draw (-0.8,1.2) -- (a) -- (0.8,1.2);
\draw (C4) -- (a) -- (C7);
\draw (0,0.4) -- (b) -- (4,0.61);
\draw (-0.8,-0.25) -- (c) -- (0.8,-0.25);
\node (L) at (3.1,-0.9) {\bfseries labels:};
\draw (L.south west) -- (L.south east);
\foreach[count=\ii]\i/\j in {a/label 1,b/label 2,c/label 3,d/label 4}
{
\node[my node] (\ii1) at (2.9,-0.9-0.4*\ii) {\strut\i};
\node (\ii2) at ([xshift=0.65cm]\ii1) {\strut-- \j};
}
\end{tikzpicture}
\end{document}
但是,如果你想使用你的图片,解决方案几乎是一样的(当然还要加上微调)。你可以执行以下操作:
\documentclass[border=2mm,tikz]{standalone}
% styles
\tikzset{my node/.style={circle,draw,inner sep=0mm,minimum size=4mm}}
\begin{document}\sffamily
\begin{tikzpicture}[line width=0.2mm,scale=1.5]
\node {\includegraphics[width=7.5cm]{left.jpg}}; % <-- change this for your picture
\node at (4.05,0.6) {\includegraphics[width=5.2cm]{right.jpg}}; % <-- change this for your picture
\node (C4) at (4.1,1.4) {};
\node (C7) at (3.3,0.55) {};
% labels
\draw[blue,dotted] (-2.1,0.61) node [black,above] {cross} node [black,below] {section} -- (2.1,0.61);
\node at (4,2) {cross section};
\node[my node] (a) at (1.85, 2) {\strut a};
\node[my node] (b) at (1.85, 0.15) {\strut b};
\node[my node] (c) at (1.85,-0.5) {\strut c};
\node[my node] (d) at (1.85,-1.15) {\strut d};
\draw (-0.8,1.2) -- (a) -- (0.8,1.2);
\draw (C4) -- (a) -- (C7);
\draw (0,0.4) -- (b) -- (4,0.61);
\draw (-0.8,-0.25) -- (c) -- (0.8,-0.25);
\node (L) at (3.1,-0.9) {\bfseries labels:};
\draw (L.south west) -- (L.south east);
\foreach[count=\ii]\i/\j in {a/label 1,b/label 2,c/label 3,d/label 4}
{
\node[my node] (\ii1) at (2.9,-0.9-0.4*\ii) {\strut\i};
\node (\ii2) at ([xshift=0.65cm]\ii1) {\strut-- \j};
}
\end{tikzpicture}
\end{document}