[Tex/LaTex] PSTricks: Dataplot

pstricks

Consider the following example:

\documentclass{article}
\usepackage{pst-plot}

\begin{document}

\savedata{\data}[{1999,6276},{2000,6827},{2001,7783},{2002,9819}]
\psset{xAxisLabel={Year},yAxisLabel={Ocapi}}
\begin{psgraph}[Ox=1999,xlabelOffset=0.5,Dy=2000]{->}(1999,0)(2004,13000){13.5cm}{8.1cm}
\dataplot[plotstyle=dots,dotstyle=o,fillcolor=red]{\data}
\end{psgraph}

\end{document}

I tried to re-use this answer from Herbert but it is not working. The error is

! Dimension too large.
<recently read> \pst@xunit 

l.8 ...000]{->}(1999,0)(2004,13000){13.5cm}{8.1cm}

If I can get a solution and an explanation as to why it is not working, I would be greatful.

Best Answer

Run with any compiler:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    axis lines=left, enlarge x limits=true,
    /pgf/number format/1000 sep={},
    xtick={1999,...,2002},
    ymin=0
]
\addplot +[only marks] table{
1999 6276
2000 6827
2001 7783
2002 9819
};
\end{axis}
\end{tikzpicture}

\end{document}

(with a wink and nod to Herbert)


With pst-plot, you need to shift your coordinates manually before you can plot them. You do this by adding

\pstScalePoints(1,1){1999 sub}{}

which subtracts 1999 from all your x coordinates. If you then adjust your plot limits to range from x=0 to 5 and use \listplot instead of \dataplot, you get the following:

\documentclass{article}
\usepackage{pst-plot}

\begin{document}

\savedata{\data}[{1999,6276},{2000,6827},{2001,7783},{2002,9819}]
\pstScalePoints(1,1){1999 sub}{}
\psset{xAxisLabel={Year},yAxisLabel={Ocapi}}
\begin{psgraph}[Ox=1999,xlabelOffset=0.5,Dy=2000]{->}(0,0)(5,13000){13.5cm}{8.1cm}
\listplot[plotstyle=dots,dotstyle=o,fillcolor=red]{\data}
\end{psgraph}

\end{document}
Related Question