如何制作带有不连通点的图表?

如何制作带有不连通点的图表?

我想做类似的事情:在此处输入图片描述

但是,我怎样才能使这些点不相连呢?

    \documentclass[12pt]{article}
    \usepackage{pgfplots}
    \usepackage{gensymb}

    \begin{document}
    \begin{tikzpicture}
    \begin{axis}[
    title={Temperature dependence of CuSO$_4\cdot$5H$_2$O solubility},
    xlabel={Temperature [\degree C]},
    ylabel={Solubility [g per 100 g water]},
    xmin=0, xmax=100,
    ymin=0, ymax=120,
    xtick={0,20,40,60,80,100},
    ytick={0,20,40,60,80,100,120},
    legend pos=north west,
    ymajorgrids=true,
    grid style=dashed,
]

\addplot[
color=blue,
mark=square,
]
coordinates {
(0,23.1)(10,27.5)(20,32)(30,37.8)(40,44.6)(60,61.8)(80,83.8)(100,114)
};
\legend{CuSO$_4\cdot$5H$_2$O}

\end{axis}
\end{tikzpicture}

\end{document}

答案1

正如我在评论中所建议的:添加only marks选项\addplot

\documentclass[12pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}% recent is 1.18)
\usepackage{siunitx}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
title={Temperature dependence of CuSO$_4\cdot$5H$_2$O solubility},
xlabel={Temperature [\si{\degreeCelsius}]},
ylabel={Solubility [g per 100 g water]},
xmin=0, xmax=100,
ymin=0, ymax=120,
xtick={0,20,40,60,80,100},
ytick={0,20,40,60,80,100,120},
legend pos=north west,
ymajorgrids=true,
grid style=dashed,
]

\addplot[
color=blue,
mark=square,
only marks  % <---
]
coordinates {
(0,23.1)(10,27.5)(20,32)(30,37.8)(40,44.6)(60,61.8)(80,83.8)(100,114)
};
\legend{CuSO$_4\cdot$5H$_2$O}

\end{axis}
\end{tikzpicture}

\end{document}

得出:

在此处输入图片描述

相关内容