
pgfplots を使用して、線と X 軸の間の角度を描画しようとしました。tikz やその他のパッケージを使用する方法はたくさんありましたが、pgfplots を使用してこれを行う方法はありますか?
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzfigure}
\begin{axis}[
axis x line = center,
axis y line = center,
xlabel = $x$,
ylabel = $y$,
xmin=-1.0,
xmax=3.0,
ymin=-1.0,
ymax=3.0,
disabledatascaling,
axis equal,
]
\addplot [->, color=blue] coordinates {(0, 0) (2, 3)};
\end{axis}
\end{tikzfigure}
\end{document}
このような角度を得るには何を書けばいいでしょうか?
答え1
直接ではありませんが、その必要性も感じません。ただし、もちろん、3 つの座標を定義して、ライブラリを使用してangles
必要な角度を描画することもできます。
% used PGFPlots v1.17
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{
angles,
quotes,
}
% use this `compat` level or higher so TikZ coordinates
% are in axis units by default
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
xlabel=$x$,
ylabel=$y$,
xmin=-1.0,
xmax=3.0,
ymin=-1.0,
ymax=3.0,
disabledatascaling,
axis equal,
]
\coordinate (xaxis) at (\pgfkeysvalueof{/pgfplots/xmax},0);
\coordinate (origin) at (0,0);
\addplot [->,blue] coordinates {(0, 0) (2, 3)}
coordinate [at end] (A)
;
\path (xaxis) -- (origin) -- (A)
pic [
draw,
->,
red,
angle radius=10mm,
angle eccentricity=1.2,
"$\theta$",
] {angle = xaxis--origin--A}
;
\end{axis}
\end{tikzpicture}
\end{document}