[pstricks] Transformation into bar chart

Herbert Voss Herbert.Voss at alumni.TU-Berlin.DE
Wed Sep 1 19:47:05 CEST 2004


Matthias Steinbrink wrote:
> 
> Wouldn't it be a 
> good idea to implement it into the "normal" packages?

sure, I can put into pstricks-add, but it needs some more testing.
Here is a better version, the first one was created with hot
needles ...  :-)

Herbert


\documentclass[12pt]{article}
\usepackage{filecontents}
\begin{filecontents*}{Daten.data}
0 0.03
1 0.11
2 0.28
3 0.84
4 6.70
5 8.55
6 8.77
7 11.09
8 7.18
9 6.20
10 5.78
11 4.19
12 2.37
13 2.26
14 1.68
15 1.03
16 1.37
17 1.34
18 0.92
19 0.67
20 0.87
21 1.20
22 1.98
23 3.99
24 5.08
25 5.17
26 5.78
27 4.44
28 0.11
\end{filecontents*}
\usepackage{pstricks,pst-plot,pstricks-add}
\parindent=0pt

\makeatletter
\def\psset at barwidth#1{\pst at getlength{#1}\psk at barwidth}
\psset at barwidth{0.25cm}
%
\def\psbar at ii{\addto at pscode{false \tx at NArray \psbar at iii}}
\def\psbar at iii{%
   newpath
   n {
     /Y exch def /X exch def
     X \number\psk at barwidth 0.5 mul sub 0 moveto
     0 Y rlineto \number\psk at barwidth 0 rlineto 0 Y neg rlineto
   } repeat
}%
\def\beginplot at bar{\begin at SpecialObj}
\def\endplot at bar{\psbar at ii\psk at fillstyle\pst at stroke\end at SpecialObj}
%
\makeatother

\begin{document}
\psset{xunit=.44cm,yunit=.3cm}
\readdata{\data}{Daten.data}
\begin{pspicture}(-2,-1.5)(29,13)
   \psaxes[axesstyle=axes,Ox=1466,Oy=0,Dx=4,Dy=2,%
      ylabelFactor={\,\%}]{-}(29,12)
   \listplot[linecolor=blue,plotstyle=bar,barwidth=0.3cm,
      fillcolor=red,fillstyle=solid]{\data}
   \rput{90}(-3,6.25){Amount}
\end{pspicture}

\begin{pspicture}(-2,-1.5)(29,13)
   \psaxes[axesstyle=axes,Ox=1466,Oy=0,Dx=4,Dy=2,%
      ylabelFactor={\,\%}]{-}(29,12)
   \listplot[linecolor=blue,plotstyle=bar,barwidth=0.3cm,
      fillcolor=red,fillstyle=crosshatch]{\data}
   \rput{90}(-3,6.25){Amount}
\end{pspicture}

\begin{pspicture}(-2,-1.5)(29,13)
   \psaxes[axesstyle=axes,Ox=1466,Oy=0,Dx=4,Dy=2,%
      ylabelFactor={\,\%}]{-}(29,12)
   \listplot[linecolor=blue,plotstyle=bar,barwidth=0.3cm,
      fillcolor=red,fillstyle=vlines]{\data}
   \listplot[showpoints=true]{\data}
   \rput{90}(-3,6.25){Amount}
\end{pspicture}

\end{document}



-- 
http://TeXnik.de/
http://PSTricks.de/
ftp://ftp.dante.de/tex-archive/info/math/voss/Voss-Mathmode.pdf
http://www.dante.de/faq/de-tex-faq/
http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes




More information about the PSTricks mailing list