我可能用错了方法,但我正尝试使用 tikz 和 pgfplots 突出显示图表上的特定点。目前,我正在使用节点围绕该点绘制一个圆圈 - 但是,我理想情况下希望将其更改为更像“x”的东西。
我的代码如下,如能得到任何帮助我将非常感激。
\documentclass[1cm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = {Good 1},
ylabel = {Good 2},
xmin=0,
xmax=450,
ymin=0,
ymax=450,
ytick={0,100,200,300,400,500},
scaled y ticks = false,
]
\addplot[] file[] {jointppf.dat};
\node[draw,circle] ( ) at (250,300) {};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您可以使用:\addplot[mark=x,mark size=3] coordinates {(250,300)};
\documentclass[1cm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = {Good 1},
ylabel = {Good 2},
xmin=0,
xmax=450,
ymin=0,
ymax=450,
ytick={0,100,200,300,400,500},
scaled y ticks = false,
]
\addplot[] coordinates
{(0,420) (250,300) (400,0)};
\addplot[mark=x,mark size=3] coordinates
{(250,300)};
\end{axis}
\end{tikzpicture}
\end{document}
或者:\node at (axis cs:250,300) {\sffamily{x}};
\documentclass[1cm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = {Good 1},
ylabel = {Good 2},
xmin=0,
xmax=450,
ymin=0,
ymax=450,
ytick={0,100,200,300,400,500},
scaled y ticks = false,
]
\addplot[] coordinates
{(0,420) (250,300) (400,0)};
\node at (axis cs:250,300) {\sffamily{x}};
\end{axis}
\end{tikzpicture}
\end{document}