TikZ 轴标签(t)位于轴右侧

TikZ 轴标签(t)位于轴右侧

我在 x 轴上堆叠了 t 节点。但 y 轴上的 F 却没有发生这种情况。你能告诉我我的代码哪里出了问题吗?我需要将“t”放在 x 轴的最右侧

在此处输入图片描述

\begin{tikzpicture}[scale=0.8]
\begin{axis}[
axis x line=center,
ylabel={$y$},
xlabel={$t$}, 
axis y line=middle,
every axis y label/.style={at={(current axis.north west)},above=2mm}, 
xtick={0,9.42 },
xticklabels={0,{2 s}},
ytick={-1,0,1},
yticklabels={-2m, 0,2m},
xmin=.0, xmax=9.6,
domain=0:3.34*pi, width=10cm,height=4cm,
samples=41,grid]
\addplot[thick, red, no marks] {sin(deg(x))};
\end{axis}
\end{tikzpicture}

答案1

我更改了你的选项every axis y label

\documentclass[border = 5pt]{standalone}

\usepackage{pgfplots}

\begin{document}

  \begin{tikzpicture}[scale=0.8]
    \begin{axis}[
      axis x line=center,
      ylabel={$y$},
      xlabel={$t$}, 
      axis y line=middle,
      every axis y label/.style={
        at={(ticklabel* cs:1.2)},
        anchor=north,
      },
      every axis x label/.style={
        at={(ticklabel* cs:1.05)},
        anchor=east,
      },
      xtick={0,9.42 },
      xticklabels={0,{2 s}},
      ytick={-1,0,1},
      yticklabels={-2m, 0,2m},
      xmin=.0, xmax=9.6,
      domain=0:3.34*pi, width=10cm,height=4cm,
      samples=41,grid]
      \addplot[thick, red, no marks] {sin(deg(x))};
    \end{axis}
  \end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容