带有子图和标题的 Tikzpicture

带有子图和标题的 Tikzpicture

我想制作下图: 在此处输入图片描述

因此,箭头上有一些垂直虚线,边缘下方有文字。我尝试使用 mathcha.io,但如果您知道如何使用 \draw、\node、\edge、\paths 等命令,那就更好了。

我遇到的主要问题是如何将不同的箭头分别作为带有标题的子图嵌入到一个图中。

请看我的代码:

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}


\begin{figure}[h]
    \centering
    \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
        %uncomment if require: \path (0,235); %set diagram left start at 0, and has height of 235
        
        %Straight Lines [id:da7385431531953355] 
        \draw    (100,16) -- (597.2,16.7) ;
        \draw [shift={(599.2,16.7)}, rotate = 180.08] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
        %Straight Lines [id:da703699466676206] 
        \draw    (247,4) -- (247.2,29.7) ;
        %Straight Lines [id:da2030449187410226] 
        \draw    (430,4) -- (430.2,29.7) ;
        
        
        % Text Node
        \draw (146,23) node [anchor=north west][inner sep=0.75pt]   [align=left] {X};
        % Text Node
        \draw (311,24) node [anchor=north west][inner sep=0.75pt]   [align=left] {Y};
        % Text Node
        \draw (492,22) node [anchor=north west][inner sep=0.75pt]   [align=left] {Z};
    \end{tikzpicture}
    \caption{Subfigure a} 
    \label{Subfigure_a}
\end{figure}

答案1

我建议使用\subcaptionbox以下方法:

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tikz}

\begin{document}
\begin{figure}
    \centering
    \subcaptionbox{subfigure a}[\textwidth]{
    \begin{tikzpicture}
        \def\length{6}   % Length of your arrow
        \def\height{0.5} % Height of your intersections
        \draw[->] (-\length,0) -- (\length,0);
        \node at (-2*\length/3,0) [yshift=-4,anchor=north]{X};
        \node at ( 0,0)           [yshift=-4,anchor=north]{Y};
        \node at ( 2*\length/3,0) [yshift=-4,anchor=north]{Z};
        \draw[-] (-\length/3,-\height/2) -- (-\length/3,\height/2);
        \draw[-] ( \length/3,-\height/2) -- ( \length/3,\height/2);
    \end{tikzpicture}
    }
    \subcaptionbox{subfigure b}[\textwidth]{
    \begin{tikzpicture}
        \def\length{6}   % Length of your arrow
        \def\height{0.5} % Height of your intersections
        \draw[->] (-\length,0) -- (\length,0);
        \node at (-2*\length/3,0) [yshift=-4,anchor=north]{X};
        \node at ( 0,0)           [yshift=-4,anchor=north]{Y};
        \node at ( 2*\length/3,0) [yshift=-4,anchor=north]{Z};
        \draw[-] (-\length/3,-\height/2) -- (-\length/3,\height/2);
        \draw[-] ( \length/3,-\height/2) -- ( \length/3,\height/2);
    \end{tikzpicture}
    }
\end{figure}
\end{document}

对我来说,这创建了一个完美居中的图形: pdf 输出

相关内容