
(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}
다른 옵션에는 s 사용이 포함됩니다 node
. pgfplots의 최신 버전(예: )을 사용하는 경우 \pgfplotsset{compat=1.16}
접두사가 필요하지 않습니다 axis cs:
.