[pstricks] reverse axes
Herbert Voss
Herbert.Voss at alumni.TU-Berlin.DE
Wed Oct 22 16:44:44 CEST 2003
Peter I. Hansen schrieb:
> Is it possible to have (0,0) in the bottom right corner, and then place
> (10,10) in the upper left or bottom left??
if you want to have the origin in the lower right replace the
line between ---YYYY with only i
Herbert
\documentclass[12pt,a4paper]{article}
\usepackage{pst-plot}
\parindent=0pt
\def\maxX{10}
\def\maxY{10}
\makeatletter
\pst at def{Grid}<{%
newpath /a 4 string def
/b ED/c ED/n ED cvi dup 1 lt { pop 1 } if
/s ED s div dup 0 eq { pop 1 } if /dy ED s div dup 0 eq { pop 1 } if
/dx ED dy div round dy mul /y0 ED dx div round dx mul /x0 ED dy div
round cvi
/y2 ED dx div round cvi /x2 ED dy div round cvi /y1 ED dx div round cvi
/x1 ED /h y2 y1 sub 0 gt { 1 } { -1 } ifelse def
/w x2 x1 sub 0 gt { 1 } { -1 } ifelse def b 0 gt { /z1 b 4 div CLW 2 div
add def
/Helvetica findfont b scalefont setfont /b b .95 mul CLW 2 div add def } if
systemdict /setstrokeadjust known { true setstrokeadjust /t { } def }
{ /t { transform 0.25 sub round 0.25 add exch 0.25 sub round 0.25 add
exch itransform } bind def } ifelse
gsave n 0 gt { 1 setlinecap [ 0 dy n div ] dy n div 2 div setdash }
{ 2 setlinecap } ifelse /i x1 def
/f y1 dy mul n 0 gt { dy n div 2 div h mul sub } if def
/g y2 dy mul n 0 gt { dy n div 2 div h mul add } if def
x2 x1 sub w mul 1 add dup 1000 gt { pop 1000 } if
{ i dx mul dup y0 moveto b 0 gt { gsave c
%-----------------------XXXXXX
\maxX\space i sub
%-----------------------XXXXXX
a cvs dup stringwidth pop /z2 ED w 0 gt {z1} {z1 z2 add neg} ifelse
h 0 gt {b neg} {z1} ifelse rmoveto show grestore
} if dup t f moveto g t L stroke /i i w add def } repeat grestore gsave
n 0 gt
{ 1 setlinecap [ 0 dx n div ] dx n div 2 div setdash }
{ 2 setlinecap } ifelse /i y1 def /f x1 dx mul
n 0 gt { dx n div 2 div w mul sub } if def /g x2 dx mul n 0 gt { dx n
div 2 div w mul add } if def y2 y1 sub h mul 1 add dup 1000 gt { pop
1000 } if { newpath i dy mul dup x0 exch moveto b 0 gt { gsave c
%-----------------------YYYYYY
\maxY\space i sub
%-----------------------YYYYYY
a cvs dup stringwidth pop /z2 ED w 0 gt {z1 z2 add neg} {z1} ifelse h 0 gt
{z1} {b neg} ifelse rmoveto show grestore } if dup f exch t moveto g
exch t L stroke /i i h add def } repeat grestore }>
\makeatother
\begin{document}
\begin{pspicture}(0,0)(\maxX,\maxY)
\psgrid[subgriddiv=0,griddots=10]
\psline[linewidth=0.2pt]{->}(0,0)(\maxX,\maxY)
\end{pspicture}
\end{document}
--
http://www.pstricks.de/
More information about the PSTricks
mailing list