PGFPlots x/yshift 不允許負數?

PGFPlots x/yshift 不允許負數?

我一直在嘗試在 axis 環境中移動 x 軸標籤向下。沒有取得多大成功......出於某種原因,當我輸入整個內容時xlabel style={yshift=-1.5em},整個事情甚至沒有編譯並向! Missing number, treated as zero.我拋出。請幫忙。

這是程式碼,請忽略亂七八糟的座標。它們是由地代數

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

在此輸入影像描述

相關內容