PGFPlots x/yshift não permite números negativos?

PGFPlots x/yshift não permite números negativos?

Tenho tentado mudar o rótulo do eixo x no ambiente do eixoabaixo. Sem muito sucesso... Por algum motivo quando entro xlabel style={yshift=-1.5em}a coisa toda nem compila e joga um ! Missing number, treated as zero.em mim. Por favor ajude.

Aqui está o código, ignore as coordenadas confusas. Eles foram gerados porGeogebra

\documentclass[tikz, border=2mm]{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{arrows.meta}

\begin{document}   

\begin{tikzpicture}
\begin{axis}[
x=2.5cm,
y=2.5cm,
axis x line=middle,
axis y line=middle,
every inner x axis line/.append style={-{Latex[scale=1.5]}},
every inner y axis line/.append style={-{Latex[scale=1.5]}},
xmin=-2,
xmax=2,
ymin=-1.5,
ymax=1.5,
xtick={-1,0,1},
ytick={-1,0,1},
xlabel={$x$},
ylabel={$y$},
xlabel style={yshift=-1.5em},
xticklabel style={xshift={1em}},
yticklabel style={yshift={1em}},
]
\draw [line width=0.4pt] (0,0) -- (0:0.4) arc (0:60:0.4) -- cycle;
\draw [line width=0.4pt] (0,0) -- (0:0.35) arc (0:20:0.35) -- cycle;
\draw [line width=0.4pt] (0,0) circle (1);
\draw [line width=0.4pt,domain=0.0:2.027730435633692] plot(\x,{(-0.--0.8660254037844386*\x)/0.5});
\draw [line width=0.4pt,domain=0.0:2.027730435633692] plot(\x,{(-0.-0.*\x)/1.});
\draw [line width=0.4pt,domain=0.0:2.027730435633692] plot(\x,{(-0.--0.3420201433256687*\x)/0.9396926207859084});
\draw [fill=black] (0,0) circle (2.0pt);
\draw[color=black] (-0.10401667920577555,0.09712413496725324) node {$S$};
\draw[color=black] (-0.6287544305508752,0.958767374391877) node {$k$};
\draw [fill=black] (1,0) circle (2.5pt);
\draw[color=black] (0.85,-0.1264857022536699) node {$A$};
\draw [fill=black] (0.5,0.8660254037844386) circle (2.5pt);
\draw[color=black] (1.117013971395119,0.8872122264811816) node {$B[\cos{\alpha}; \sin{\alpha}]$};
\draw[color=black] (0.43,0.24) node {$\alpha$};
\draw [fill=black] (0.9396926207859084,0.3420201433256687) circle (2.5pt);
\draw[color=black] (1.522992684288592,0.2400490757514338) node {$C[\cos{\frac{\alpha}{3}}; \sin{\frac{\alpha}{3}}]$};
\draw[color=black] (0.5450723295090882,0.09639927698213733) node {$\frac{\alpha}{3}$};
\end{axis}
\end{tikzpicture}

\end{document}

Responder1

Bem-vindo ao TeX.SE. Todos os problemas de compilação que encontrei no seu código vêm do uso de circle (〈r〉)sintaxe obsoleta. Use circle[radius=〈r〉]em vez disso e funciona.

Oxa etiqueta é colocada como você deseja. Outra possibilidade seria usar xlabel style={anchor=north}. Você também pode combinar ambos anchore yshiftpara ajuste fino ou usar inner sepou inner ysepcomo em xlabel style={anchor=north, inner sep=1ex}.

Para mais detalhes, consulteEdição 232 da PGF(tambémesseeque).

\documentclass[tikz, border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[
    x=2.5cm,
    y=2.5cm,
    axis x line=middle,
    axis y line=middle,
    every inner x axis line/.append style={-{Latex[scale=1.5]}},
    every inner y axis line/.append style={-{Latex[scale=1.5]}},
    xmin=-2,
    xmax=2,
    ymin=-1.5,
    ymax=1.5,
    xtick={-1,0,1},
    ytick={-1,0,1},
    xlabel={$x$},
    ylabel={$y$},
    xlabel style={yshift=-1.5em},
    xticklabel style={xshift={1em}},
    yticklabel style={yshift={1em}},
    ]
    \draw [line width=0.4pt] (0,0) -- (0:0.4) arc (0:60:0.4) -- cycle;
    \draw [line width=0.4pt] (0,0) -- (0:0.35) arc (0:20:0.35) -- cycle;
    \draw [line width=0.4pt] (0,0) circle[radius=2.5cm];
    \draw [line width=0.4pt,domain=0.0:2.027730435633692] plot(\x,{(-0.--0.8660254037844386*\x)/0.5});
    \draw [line width=0.4pt,domain=0.0:2.027730435633692] plot(\x,{(-0.-0.*\x)/1.});
    \draw [line width=0.4pt,domain=0.0:2.027730435633692] plot(\x,{(-0.--0.3420201433256687*\x)/0.9396926207859084});
    \draw [fill=black] (0,0) circle[radius=2.0pt];
    \draw[color=black] (-0.10401667920577555,0.09712413496725324) node {$S$};
    \draw[color=black] (-0.6287544305508752,0.958767374391877) node {$k$};
    \draw [fill=black] (1,0) circle[radius=2.5pt];
    \draw[color=black] (0.85,-0.1264857022536699) node {$A$};
    \draw [fill=black] (0.5,0.8660254037844386) circle[radius=2.5pt];
    \draw[color=black] (1.117013971395119,0.8872122264811816) node {$B[\cos{\alpha}; \sin{\alpha}]$};
    \draw[color=black] (0.43,0.24) node {$\alpha$};
    \draw [fill=black] (0.9396926207859084,0.3420201433256687) circle[radius=2.5pt];
    \draw[color=black] (1.522992684288592,0.2400490757514338) node {$C[\cos{\frac{\alpha}{3}}; \sin{\frac{\alpha}{3}}]$};
    \draw[color=black] (0.5450723295090882,0.09639927698213733) node {$\frac{\alpha}{3}$};
    \end{axis}
\end{tikzpicture}

\end{document}

insira a descrição da imagem aqui

informação relacionada