0

I'm trying to detail my plots using TikZ overlay. My current code is:

\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}

This provides me the following figure: enter image description here

However, I'd like to detail my figure as follow:

enter image description here

Please note that, I also want to have a dotted or dashed-dotted line (horizontal line on the left figure) as the cross section line.

The 2 image files I'm using are attached. enter image description here

enter image description here

I appreciate your help.

Rahman
  • 189

1 Answers1

2

IMHO, your picture is simple enough to be drawn directly with TikZ. Then you can avoid the fine tuning to adjust positions, scales, matching colors,...

For example, with this code:

\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 {}; \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}

you'll get: enter image description here

However, if you want to use your pictures, the solution is almost the same (plus the fine tuning, of course). You can do the following:

\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}

and with this you'll get: enter image description here

Juan Castaño
  • 28,426