
(2,2) に黒い円形の点が表示されることを期待していましたが、何も表示されません。
私が使用しているコードは次のとおりです
\documentclass[]{article}
\usepackage{amsmath}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
restrict y to domain=-10:10,
restrict x to domain=-5:5,
xlabel=$x$,
ylabel=$y$,
xmin=-4,
xmax=4,
xtick={-4,-2,...,4},
ymin=-4,
ymax=4,
ytick={-4,-2,...,3},
axis lines=center,
axis equal,
smooth,
scale=0.8
]
\addplot [] {(x-2)^3-3*x+6};
\coordinate
[
label=above:{$(2,2)$},
black,
mark=*,
] (a) at (axis cs:2,2);
\end{axis}
\end{tikzpicture}
\end{document}
つまり、ソフトウェアは (2,2) に座標があることを理解できるのですが、それを表示していないだけです。なぜこのようなことが起こるのか、誰か考えがあるでしょうか?
答え1
座標には (ノード) コンテンツがありません。構文をほぼ完全に維持するために、cmark
座標の中央にプロット マークを追加するスタイルを追加しました。
\documentclass[]{article}
\usepackage{amsmath}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[cmark/.style={label={[anchor=center]:\pgfuseplotmark{#1}}}]
\begin{axis}
[
restrict y to domain=-10:10,
restrict x to domain=-5:5,
xlabel=$x$,
ylabel=$y$,
xmin=-4,
xmax=4,
xtick={-4,-2,...,4},
ymin=-4,
ymax=4,
ytick={-4,-2,...,3},
axis lines=center,
axis equal,
smooth,
scale=0.8
]
\addplot [] {(x-2)^3-3*x+6};
\coordinate
[
label=above:{$(2,2)$},
black,
cmark=*,
] (a) at (axis cs:2,2);
\end{axis}
\end{tikzpicture}
\end{document}
その他のオプションには の使用が含まれますnode
。 など、十分に新しいバージョンの pgfplots を使用する場合は、プレフィックス\pgfplotsset{compat=1.16}
は不要であることに注意してくださいaxis cs:
。