PGFPlots x/yshift 不允许负数?

PGFPlots x/yshift 不允许负数?

我一直在尝试在轴环境中移动 x 轴标签向下。没有取得多大成功...出于某种原因,当我输入xlabel style={yshift=-1.5em}整个内容时,它甚至无法编译,并向! Missing number, treated as zero.我抛出一个。请帮忙。

以下是代码,请忽略混乱的坐标。它们是由Geogebra

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

答案1

欢迎使用 TeX.SE。我发现您的代码中的所有编译问题都源自使用弃用的circle (〈r〉)语法。改用circle[radius=〈r〉]它就可以了。

X标签可按您的需要放置。另一种可能性是使用xlabel style={anchor=north}。您还可以结合使用anchoryshift进行微调,或者使用inner sep或 ,inner ysep如 中所示xlabel style={anchor=north, inner sep=1ex}

有关详细信息,请参阅PGF 问题 232(还)。

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

在此处输入图片描述

相关内容