3

I'm trying to create a graph which has all of the datapoints from an inline table plotted, without a line connecting them, but still having the points on the graph.

The issue with the MWE is the line connecting all the points.

MWE:

\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}
\pgfplotstableread{
   1 1
   2 2
   3 3
   4 4
}\datatable

\begin{tikzpicture}
   \begin{axis}
      \addplot table \datatable;
   \end{axis}
\end{tikzpicture}

\end{document}
PTNobel
  • 356
  • 1
  • 14

1 Answers1

1

I have something similar in my examples. May be it will help you. I drew an extra line which is optional

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc, intersections}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
major grid style=gray,
axis lines=center,
xmin=0, xmax=0.7,
ymin=0, ymax=7,
xtick={0,0.10,...,0.70},
ytick={0,1,...,6.5},
tick label style={font=\tiny},
width=\textwidth,
height=7 cm,
xlabel={$F$(N)},
ylabel={$\Delta l$(m)},
minor xtick={0,0.02,...,0.65},
minor ytick={0,0.2,...,7},
grid=both,
]
\addplot[color = black,  mark=triangle*, mark size=1.5, only marks] coordinates{(0.20,1.96) (0.30,2.95) (0.40,3.92) (0.50,4.92) (0.60,5.88)};
\addplot[black, domain=0:0.65, no markers,samples=3] {9.81*x} ; 
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here