0

I want to move the xlabel "t" to the right end of the x-axis. I tried x label style, but it does not work for me somehow. What else could I try?

I'd be fine with a separate node or also with a "$t \rightarrow$" somewhere below the graphs of the functions, but unfortunately I failing at doing this.

Any hint or help is appreciated. Thank you in advance!

\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}

enter image description here

4
  • 1
    Add xlabel style={ xshift=1.5em}, and remove axis x line=middle, Oct 20, 2023 at 21:18
  • Thank you, that worked! I also found every axis x label/.style={at={(ticklabel* cs:1.05)},anchor=west} to be working.
    – user408858
    Oct 20, 2023 at 21:49
  • To help other readers put compilable code as an answer, from \documentclass to \end{document} (with only the necessary packages) and its output. Then you can accept your own answer. Oct 20, 2023 at 21:56
  • Ay news? Do you check received answers? Is no one worth to be awarded by upvoting it? Some of them addresses some other issues of your code fragment ...
    – Zarko
    Nov 21, 2023 at 7:59

2 Answers 2

1
  • Please always provide MWE (Minimal Working Example), a small but complete document, which we can test/compile as it is.
  • Since you not provide it, the preamble content, which is related to diagram, is unknown.
  • You need to cleanup axis settings (for example, axis are defined several times).
  • The xlabel style works as expected, see MWE below.
  • It seems that culprit of your troubles is unusual definition of the x axis line style. What you like to achieve with it you can get by use of the enlarge x limits.
  • See, if the following MWE produces what you after:
\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}

enter image description here

0
\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}

enter image description here

1
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 22, 2023 at 0:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .