如何转变情节

如何转变情节

我想在同一个图中绘制几个图tikzpicture(我不确定是否还有其他方法可以做到这一点)阴谋中的函数tikz。代码为:

\documentclass[preview,border=2pt,2pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{arrows.meta}
\tikzset{decorate sep/.style 2 args=
    {decorate,decoration={shape backgrounds,shape=circle,shape size=#1,shape sep=#2}}}
\tikzset{>={Latex[width=1mm,length=3mm]}}

\begin{document}    
\begin{tikzpicture}
    \tikzstyle{line} = [arrows=<->,line width=0.6pt]
    \tikzstyle{line1} = [line width=.1pt]

    \def\r{0.5pt} %define the radius of spot
    \def\ax{3.3} %define the length of x-axis
    \def\ay{4} %define the length of y-axis
    \def\y{3} %define the height of T=1
    \def\u{4} %define the origin of the second plot
    \def\v{8} %define the origin of the third plot

    \tikzset{
        declare function={
            normpdf(\x,\m,\s,\r)=\r*exp(-((\x-\m)/\s)^4);
        }
    }

    \draw[line] (0,\ay) coordinate node [below left] {$T$} -- (0,0) coordinate node[below] {$0$} -- (\ax, 0) coordinate node [below left] {$x$};
    \draw[scale=1, domain=0:2, smooth, variable=\x] plot ({\x}, {normpdf(\x,0,1.3,\y)});

    \node[left] at (0,\y) {$1$};
    \node[above] at (\ax/2,\y) {(i) $ I_t=[0,\alpha(t)]$};
    \draw[line1] (0, 2.1) -- (1,2.1) -- (1,0);
    \node[below] at (1,0) {$\alpha(t)$};
 
    \draw[line] (\u,\ay) coordinate node [below left] {$T$} -- (\u,0) coordinate node[below] {$0$} -- (\ax+\u, 0) coordinate node [below left] {$x$};
    \draw[scale=1, domain=-2:0, smooth, variable=\x] plot ({\x}, {normpdf(\x,0,1.3,\y)});
     
     \node[left] at (\u,\y) {$1$};
     \node[above] at (\ax/2+\u,\y) {(ii) $ I_t=[\alpha(t),c]$};
     \draw[line1] (\u, 2.1) -- (\u+1,2.1) -- (\u+1,0);
     \node[below] at (\u+1,0) {$\alpha(t)$};
    
\end{tikzpicture}
\end{document}

问题是如何将情节转移到第二到 指定的另一个来源\u ( "\draw[scale=1, domain=-2:0, smooth, variable=\x] plot ({\x}, {normpdf(\x,0,1.3,\y)})")。谢谢。

答案1

您可以使用与第一个相同的坐标设计第二个图,并(x,y)使用以下向量将其移动

\begin{shift}[shift={(x,y)}]
...
\end{shift}

这使您可以重复使用相同的部分,如下所示。

在此处输入图片描述

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}    

\begin{tikzpicture}[
  line/.style={arrows=<->,line width=0.6pt},
  line1/.style={line width=.1pt},
  declare function={normpdf(\x,\m,\s,\r)=\r*exp(-((\x-\m)/\s)^4);},
  >={Latex[width=1mm,length=3mm]}
  ]

  \def\r{0.5pt} %define the radius of spot
  \def\ax{3.3} %define the length of x-axis
  \def\ay{4} %define the length of y-axis
  \def\y{3} %define the height of T=1
  \def\u{4} %define the origin of the second plot
  \def\v{8} %define the origin of the third plot

  \newcommand\myplot[1]{%
    \draw[line] (0,\ay) node [below left] {$T$} -- (0,0) node[below] {$0$} -- (\ax, 0) node [below left] {$x$};
    \draw[scale=1, domain=0:2, smooth, variable=\x] plot ({\x}, {normpdf(\x,0,1.3,\y)});
    \draw[line1] (0, 2.1) -| (1,0) node[below] {$\alpha(t)$};
    \node[left] at (0,\y) {$1$};
    \node[above] at (\ax/2,\y) {#1};
  }

  \myplot{(i) $I_t=[0,\alpha(t)]$}
  \begin{scope}[shift={(\u,0)}]
    \myplot{(ii) $I_t=[\alpha(t),c]$}
  \end{scope}    
\end{tikzpicture}

\end{document}

相关内容