将 xlabel 向右移动(x 标签样式不起作用?)

将 xlabel 向右移动(x 标签样式不起作用?)

我想将 xlabel“t”移动到 x 轴的右端。我尝试了 x label 样式,但不知为何不起作用。我还能尝试什么?

我可以使用单独的节点或者在函数图下方的某处使用“$t \rightarrow$”,但不幸的是我没能做到这一点。

任何提示或帮助都值得感激。提前谢谢您!

\begin{figure}
    %\centering
    \begin{tikzpicture}
        \begin{axis}[
            minor tick num=0,
            axis lines  = middle,
            axis line style = {shorten > =-5mm},
            xlabel       = {$t$},
            %xlabel={$t$ \diagramarrow},
            axis y line=left,
            axis x line=middle,
            width=1.0*\textwidth,
            height=0.55*\textwidth,
            %xlabel=$x$,ylabel=$\sin x$,
            xtick={3.14159,2*3.14159,3*3.14159,4*3.14159,5*3.14159,6*3.14159,6.5*3.14159},
            yticklabels=\empty,
            xticklabels={ , $2\pi$, , $4\pi$, , , $\frac{13}{2}\pi$ },
            %every axis/.append style={font=\small},
            ymax=8,
            ymin=-8,
            legend cell align={left},
            legend style={at={($(0.26,1)$)},nodes={scale=1.5, transform shape}},
            %xmin = -1,
            y axis line style={<->}
        ]
            %node[pos=42355, below=2352350, scale=12]{$t\longrightarrow$}
            \addplot[smooth,teal,mark=none, densely dashed, thick,
            domain=0:0.65*31.4159,samples=1000]
                { cos(deg(x))};
                \addlegendentry[scale=0.6]{$\gamma_{0,1}$}
                %node [pos=0.5, below=200, scale=0.8] {$\gamma_{0,1}=\cos t$};
            \addplot[smooth,red,mark=none,  densely dotted, thick,domain=0:0.65*31.4159,samples=1000]
                { ( (3/8)*x*cos(deg(x)) - (9/32)*sin(deg(x)) - (1/32) * sin(3*deg(x))  )};
                \addlegendentry[scale=0.6]{$\gamma_{1,1}$}
                %node [pos=0.5, below=200, scale=0.8] {$\gamma_{0,1}=\cos t$};
            \addplot[smooth,blue,mark=none,thick,  domain=0:0.65*31.4159,samples=1000]
                { cos(deg(x)) + 0.5*((3/8)*x*cos(deg(x))-(9/32)*sin(deg(x))-(1/32)*sin(3*deg(x))  )};
                \addlegendentry[scale=0.6]{$\gamma_{0,1}+\varepsilon\gamma_{1,1}$}
                %node [pos=0.5, below=200, scale=0.8] {$\gamma_{0,1}=\cos t$};
        \end{axis}
    \end{tikzpicture}
    }
    \end{figure}

在此处输入图片描述

答案1

  • 请始终提供 MWE(最小工作示例),一个小但完整的文档,我们可以按原样测试/编译它。
  • 由于您没有提供,与图表相关的前言内容是未知的。
  • 您需要清理axis设置(例如,轴被定义多次)。
  • 工作xlabel style如预期,请参见下面的 MWE。
  • 看来,您遇到的麻烦的罪魁祸首是对 的定义不寻常x axis line style。 您可以使用 来实现您想要实现的目标enlarge x limits
  • 看看以下 MWE 是否产生了您想要的结果:
\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
    \begin{tikzpicture}
\begin{axis}[
    height=0.55*\textwidth,
    width=\textwidth,
%
    axis lines = center,
    y axis line style={stealth-stealth},
    enlarge x limits = {0.1, upper},
    xlabel = {$t$},
    xlabel style = {anchor=west},
%
    trig format= rad,
    xtick = {pi,2*pi,3*pi,4*pi,5*pi,6*pi},
    xticklabels = {$\pi$, $2\pi$, $3\pi$, $4\pi$, $5\pi$, $6\pi$,$6.5\pi$},
    ytick = \empty,
    ticklabel style = {font=\scriptsize},
%
    domain= 0:6*pi, samples=301,
    no marks,
every axis plot post/.append style={thick},
%
    legend pos = north west,
    legend cell align={left},
    legend style={font=\scriptsize},
            ]
\addplot[teal, densely dashed]  {cos(x)};
\addplot[red,  densely dotted]  {(3/8)*x*cos(x) - (9/32)*sin(x) - (1/32)*sin(3*x)};
\addplot[blue]  {cos(x) + 0.5*(3/8)*x*cos(x) - (9/32)*sin(x)-(1/32)*sin(3*x)};
%
\legend{$\gamma_{0,1}$, $\gamma_{1,1}$, $\gamma_{0,1}+\varepsilon\gamma_{1,1}$}
\end{axis}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

\begin{tikzpicture}
        \begin{axis}[
            minor tick num=0,
            axis lines  = middle,
            axis line style = {shorten > =-5mm},
            axis y line=left,
            axis x line=middle,
            width=1.0*\textwidth,
            height=0.55*\textwidth,
            %xlabel=$x$,ylabel=$\sin x$,
            xtick={3.14159,2*3.14159,3*3.14159,4*3.14159,5*3.14159,6*3.14159,6.5*3.14159},
            yticklabels=\empty,
            xticklabels={ , $2\pi$, , $4\pi$, , , $\frac{13}{2}\pi$ },
            every axis/.append style={font=\scriptsize},
            ymax=8,
            ymin=-8,
            legend cell align={left},
            legend style={at={($(0.21,1)$)},nodes={scale=1.2, transform shape}},
            y axis line style={<->},
            every axis x label/.style={at={(ticklabel* cs:1.05)},anchor=west},
            xlabel       = {$t$}
            %xlabel style={ xshift=2em}
        ]
            %node[pos=42355, below=2352350, scale=12]{$t\longrightarrow$}
            \addplot[smooth,teal,mark=none, densely dashed, thick,
            domain=0:0.65*31.4159,samples=1000]
                { cos(deg(x))};
                \addlegendentry[scale=0.6]{$\gamma_{0,1}$}
                %node [pos=0.5, below=200, scale=0.8] {$\gamma_{0,1}=\cos t$};
            \addplot[smooth,red,mark=none,  densely dotted, thick,domain=0:0.65*31.4159,samples=1000]
                { ( (3/8)*x*cos(deg(x)) - (9/32)*sin(deg(x)) - (1/32) * sin(3*deg(x))  )};
                \addlegendentry[scale=0.6]{$\gamma_{1,1}$}
                %node [pos=0.5, below=200, scale=0.8] {$\gamma_{0,1}=\cos t$};
            \addplot[smooth,blue,mark=none,thick,  domain=0:0.65*31.4159,samples=1000]
                { cos(deg(x)) + 0.5*((3/8)*x*cos(deg(x))-(9/32)*sin(deg(x))-(1/32)*sin(3*deg(x))  )};
                \addlegendentry[scale=0.6]{$\gamma_{0,1}+\varepsilon\gamma_{1,1}$}
                %node [pos=0.5, below=200, scale=0.8] {$\gamma_{0,1}=\cos t$};
        \end{axis}
    \end{tikzpicture}

在此处输入图片描述

相关内容