I want to plot a graph with the format looking like this (with a line) but Latex only gives me this with an error of Dimension too large.
This is my latex file
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
ytick={2,3,4,5,6,7,8,9,10},
xtick={15000,25000,35000},
xmax=35000,
xmin=15000,
ymax=10,
ymin=2,
ylabel=Number of Groupings,
xlabel= Total tests used,
height=6cm,
width=10cm,
/pgf/number format/fixed,
/pgf/number format/precision=3,
domain=0:10
]
\addplot[mark=*,blue]
table {compare.dat};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
This is my dat file
x y
2 30000
3 22494
4 19906
5 18974
6 19779
7 18971
8 19390
9 19953
10 20612
How can I fix it?
You must choose (or let pgfplots choose for you) axis ranges which at least contain some of your data points.
With
xmax=35000,
xmin=15000,
ymax=10,
ymin=2,
you exclude each and every single data point, so pgfplots is having trouble to scale the non-existent graph you want it to draw.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{filecontents*}[overwrite]{compare.dat}
x y
2 30000
3 22494
4 19906
5 18974
6 19779
7 18971
8 19390
9 19953
10 20612
\end{filecontents*}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
% ytick={2,3,4,5,6,7,8,9,10},
% xtick={15000,25000,35000},
% xmax=35000,
% xmin=15000,
% ymax=10,
% ymin=2,
ylabel=Number of Groupings,
xlabel= Total tests used,
height=6cm,
width=10cm,
/pgf/number format/fixed,
/pgf/number format/precision=3,
domain=0:10
]
\addplot[mark=*,blue]
table {compare.dat};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}