如何製作具有未連接點的圖表?

如何製作具有未連接點的圖表?

我想做一些類似的事情:在此輸入影像描述

但是,如何才能使這些點不相連呢?

    \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}

這給出:

在此輸入影像描述

相關內容