这是一张图形,我想问一下如何将“s_1”命名为与“s_2”相同,这意味着如果你编译它,那么你会看到“s_1”位于曲线的右侧,我想将其命名为“s_2”。
另外,我怎样才能将“T”放在(0,T)处?
\documentclass[10pt]{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}{}
\frametitle{Key lemmas}
\framesubtitle{The weak maximum (minimum) principle}
For two continuous curves $s_1$, $s_2$ such that $s_1(t)<s_2(t), t\in[0,T]$, let us set $\displaystyle E_T:=\{(x,t): s_{1}(t)<x<s_{2}(t),\ 0<t\leq T\}$ and $\displaystyle B_T:=\{(s_{i}(t),t): 0\leq t\leq T,\ i\in\{1,2\}\}\cup\{(x,0): s_{1}(0)< x< s_{2}(0)\}$.
\begin{tikzpicture}
\draw[help lines, color=gray!30, dashed] ;
\draw[->,] (-4,0)--(5.5,0) node[right]{$x(position)$};
\draw[->,](0,0)--(0,3) node[above]{$t(time)$};
\draw[scale=1,domain=1:4,smooth,variable=\x,red,ultra thick] plot ({\x},{\x-1}) node[right]{$s_2$};
\draw [scale=1,domain=-2:-0.5,smooth,variable=\x,red,ultra thick] plot ({\x},{(-2)*\x-1}) node[left]{$s_1$};
\draw[scale=1,domain=-0.5:1,smooth,variable=\x,red,ultra thick] plot ({\x},{0});
\draw[scale=1,domain=-3:5.5,smooth,variable=\x,blue,dashed] plot ({\x},{2});
\end{tikzpicture}
\end{frame}
\end{document}
答案1
像这样?
关键变化是交换第一个 中的域顺序\draw .. plot
。也就是说,使用domain=-0.5:-2
而不是domain=-2:-0.5
。当您像这样node {..}
在 的末尾附加 时\draw plot
,节点将放置在最后绘制的点处。通过交换域规范中的顺序,最左边的点最后绘制,因此 s_1 节点最终位于您在图像中看到的位置。
(在正常路径中,例如\draw (0,0) -- (2,2);
,您可以pos=0
在节点选项中使用将节点移动到路径的开头,但对于 ,这不起作用plot
。)
我从你的代码中删除了一些不必要的东西。variable=\x
是默认的,所以你不必指定它,并且smooth
对于线性函数来说是没有意义的。scale=1
似乎也没有必要。
\documentclass[10pt]{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\frametitle{Key lemmas}
\framesubtitle{The weak maximum (minimum) principle}
For two continuous curves $s_1$, $s_2$ such that $s_1(t)<s_2(t), t\in[0,T]$,
let us set $\displaystyle E_T:=\{(x,t): s_{1}(t)<x<s_{2}(t),\ 0<t\leq T\}$ and
$\displaystyle B_T:=\{(s_{i}(t),t): 0\leq t\leq T,\ i\in\{1,2\}\}\cup\{(x,0): s_{1}(0)< x< s_{2}(0)\}$.
\begin{tikzpicture}[samples=2]
\draw [->] (-4,0) -- (5.5,0) node[right]{$x$ (position)};
\draw [->] (0,0) -- (0,3) node[above]{$t$ (time)};
% the domain is changed in the following line
\draw [domain=-0.5:-2,red,ultra thick] plot ({\x},{(-2)*\x-1}) node [left] {$s_1$};
\draw [domain=-0.5:1,red,ultra thick] plot ({\x},{0});
\draw [domain=1:4,red,ultra thick] plot ({\x},{\x-1}) node [right] {$s_2$};
\draw [domain=-3:5.5,blue,dashed] plot ({\x},{2});
\node [above right] at (0,2) {(0,T)};
\end{tikzpicture}
\end{frame}
\end{document}