6

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.

2 Answers 2

7

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}
2
  • 1
    Thank you, Jake. I will be glad if the plot can be made with pst-plot but if I don't get an PSTricks answer, I will accept your answer. Feb 8, 2013 at 16:52
  • @SvendMortensen: I figured out the PSTricks issue: pst-plot doesn't internally rescale the data like PGFPlots does, which is why you get the dimension too large errors. You need to manually shift your data first. I've edited my answer.
    – Jake
    Feb 8, 2013 at 17:19
4
\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]{->}(0,0)(5,13000){10cm}{6cm}
\pstScalePoints(1,1){ 1999 sub }{}
\listplot[showpoints,linecolor=red,linewidth=1pt]{\data}
\end{psgraph}

\end{document}
4
  • What is the difference between this answer and Jake's? Am I missing something obvious? Feb 8, 2013 at 19:28
  • 2
    using showpoints instead of setting dots and a line
    – user2478
    Feb 8, 2013 at 19:42
  • 1
    @SvendMortensen: I don't see. Where did I set a line in the PSTricks approach?
    – Jake
    Feb 9, 2013 at 0:30
  • @Jake. I looked at the pst-plot code instead of the pgfplots code. Sorry. (Maybe Herbert did the same thing.) Feb 9, 2013 at 2:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .