[Tex/LaTex] Undefined control sequence – \psset

pstricks

I am trying to build the image on this page:

enter image description here

When I execute "tex Cartesian_coordinates_2D.tex" eventually I get the error:

! Undefined control sequence.
\psaxes@vii ... \pst@dimd {#6}\pst@dima =\dimexpr
                                              \pst@dima -\pst@dimg \rela...
<to be read again>
               \psset
l.8 \psset
      {linewidth=.4pt}
?

This is the first time I've used Tex so I don't know what to do.

This is TeX, Version 3.14159265 (MiKTeX 2.9.6100 64-bit)
Windows 7 Pro x64

[edit]

Alternately, when I try to run the script in Texworks I get the following error:

! Package xkeyval Error: xkeyval loaded before \documentclass.
See the xkeyval package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.62 ...yval loaded before \protect\documentclass}
                                              %
? 

Best Answer

You need to compile this with either latex > dvips > ps2pdf or xelatex:

enter image description here

\documentclass{article}

\usepackage{pst-node,pst-plot}

\begin{document}

\psset{linecolor=black,linewidth=1pt,arrowsize=8pt,unit=0.29cm}
\begin{pspicture}(-15.3,-15.3)(17.4,15.3)

  % Axes
  \psaxes[Dx=5,Dy=5]{<->}(0,0)(-14.5,-14.5)(14.5,14.5)
  \psset{linewidth=.4pt}
  \psaxes[Dx=1,Dy=1,labels=none,ticksize=1.5pt](0,0)(-13,-13)(13,13)
  \uput{10pt}[0](0,14){\psscalebox{1.25}{\itshape y-axis}}
  \uput{10pt}[70](14,0){\psscalebox{1.25}{\itshape x-axis}}

  % Origin
  \pnode(0,0){O}
  \uput{35pt}[310](0,0){\rnode{Ot}{\psscalebox{1.1}{
          \vbox{\halign{\hfil#\hfil\cr$(0,0)$\cr\itshape origin\cr}}}}}
  \nccurve[angleA=315,angleB=145,arrowsize=4pt,
          nodesepA=2pt,nodesepB=-3pt,linecolor=gray]{<-}{O}{Ot}

  % Point
  \psdots[dotstyle=*,dotscale=1.2](3,5)
  \psline[linestyle=dotted,linewidth=.8pt](3,0)(3,5)(0,5)
  \uput{2.5pt}[53](3,5){\psscalebox{1.1}{$P(3,5)$}}

  % Quadrants
  \uput{3cm}[45](0,0){\psscalebox{1.6}{\bfseries I}}
  \uput{3cm}[135](0,0){\psscalebox{1.6}{\bfseries II}}
  \uput{3cm}[225](0,0){\psscalebox{1.6}{\bfseries III}}
  \uput{3cm}[315](0,0){\psscalebox{1.6}{\bfseries IV}}

\end{pspicture}

\end{document}
Related Question