tikz 记住图片 - 如何根据图片的高度或宽度设置坐标?

tikz 记住图片 - 如何根据图片的高度或宽度设置坐标?

使用 tikz 绘制线条时,是否可以使用记住图片参数来设置基于图片高度或宽度的坐标?例如,在下面的代码中

\draw [-stealth, ultra thick,] ($(image1.south)+(0,0)$)--($(bar1.west)+(1,0)$);

如果我希望线条在 bar1 宽度的 20% 处结束,我该如何设置+(1,0)(0.2*bar1.width,0)

平均能量损失

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{float}
\usepackage{subfig}
\usetikzlibrary{calc}
\usepackage{graphicx}
\begin{document}



\begin{figure*}
\centering
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}

\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0] (image1) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-b}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}

\noindent\begin{tabular}{@{}rl}     
    True Left & 
    \begin{tikzpicture}[remember picture] 
        \node[anchor=south west,inner sep=0] (bar1) at (0,0) {\includegraphics[width=0.85\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip]{example-image-a}};
    \end{tikzpicture}\\
    Pred Left &\includegraphics[width=0.85\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip]{example-image-a}\\
    True Right &\includegraphics[width=0.85\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip]{example-image-a}\\
    Pred Right &\includegraphics[width=0.85\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip]{example-image-a}\\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\begin{scope}
    \draw [-stealth, ultra thick,] ($(image1.south)+(0,0)$)--($(bar1.west)+(1,0)$);
    \end{scope}
\end{tikzpicture}
\caption{}
\label{fig:qualitative-mocap}
\end{figure*}

\end{document}

在此处输入图片描述

答案1

您可以使用let如下语法:

\draw
  let \p1=(bar1.west), \p2=(bar1.east), \n1={0.2*(\x2-\x1)} in
 [-stealth, ultra thick,] ($(image1.south)+(0,0)$)--($(bar1.west)+(\n1,0)$);

或者你可以这样做:

\draw  [-stealth, ultra thick,] ($(image1.south)+(0,0)$)--($(bar1.west)!0.2!(bar1.east)$);

相关内容