[pstricks] Transformation into bar chart

Herbert Voss Herbert.Voss at alumni.TU-Berlin.DE
Tue Aug 31 23:36:54 CEST 2004


Matthias Steinbrink wrote:
> Hello PSTricks-user,
> 
> I hope that I dont ask a too silly question.

not really a silly question ... :-)

I don't know if you want "real" bars or only something like stairs.

Herbert

\documentclass{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}
\makeatletter
\pst at def{ScalePoints}<%
   /y ED /x ED
   counttomark
   /m exch def /n m 2 div cvi def
   n 1 sub {
     dup /oldY exch def % save the y value
     m 1 roll m 1 roll  % y x roll to the end
     /m m 1 add def     % increase m
     oldY m 1 roll      % roll y to the beginning
     /m m 1 add def     % increase m
     exch dup m 1 roll  % roll the new x to the end
     exch               % change y x
   } repeat
   counttomark dup dup cvi eq not { exch pop } if
   /m exch def /n m 2 div cvi def
   n {
     y mul m 1 roll
     x mul m 1 roll
     /m m 2 sub def
   } repeat>
\makeatother
\begin{document}
   \psset{xunit=.22cm,yunit=.3cm}
   \begin{figure}[h]
     \begin{center}
       \begin{pspicture}(-5.5,-1.5)(29,13)
         \psaxes[axesstyle=axes,%
                    Ox=1466,Oy=0,Dx=4,Dy=2,%
                    ylabelFactor={\,\%}]{-}(29,12)
         \readdata{\data}{Daten.data}
         \listplot[plotstyle=line]{\data}
         \rput{90}(-5.5,6.25){Amount}
      \end{pspicture}
     \end{center}
   \end{figure}
\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