On 24-Nov-99 joost witteveen wrote: >> I want to produce some simple bar charts showing the difference >> between different products. Gnuplot doesn't seem to be able to do >> what I want (just nice clean bars with numbers at the tops and >> descriptions at the bottom). > >> Is there a good program to do this easily? Preferrably something I >> can run from a makefile... > > Well, I'm not claiming the stuff below is good:). But is is > easy, and you can generate it from a makefile (just make the > makefile insert your own table where I now got that postscript > array). > > %!PS > > /width 10 def > > /r{(bar.ps) run} def > > [ > [10 (foo)] > [20 (bar)] > [30 (foobar)] > [29 (fooba)] > [50 (fbfb)] > [20 (bar)] > ] > > /bar { > aload pop > /title exch def > /y exch def > gsave > 0.5 setgray > width 0 rlineto > 0 y rlineto > width -1 mul 0 rlineto > closepath > fill > grestore > gsave > width 2 div y width 2 div add rmoveto 90 rotate title show > grestore > } def > > /Times-Roman findfont 10 scalefont setfont > 100 100 moveto > { > width 0 rmoveto > bar > } forall > > showpage
Nice PS, Joost! Folks, don't forget the power of PIC. It's sitting there as part of groff. Example: make a file called barchart with the following contents: 8<------- cut here --------------------- .LP .PS vscale = 4 define bar { x = $1 y1 = $2/vscale ylabel = $2 line from x,0 to (x+0.25),0 to (x+0.25),y1 line from (x+0.25),y1 to (x-0.25),y1 sprintf("%0.2f",ylabel) above line from (x-0.25),y1 to (x-0.25),0 to x,0 line from (x-0.2,-0.2) to (x,0) invis $3 rjust aligned } define barchart { i=i+1 y = $2 bar(i,y,$1) } i=0 copy "bar.dat" thru barchart .PE 8<------- cut here --------------------- and a data file called "bar.dat" with contents: 8<------- cut here --------------------- "widget" 15.0 "bidget" 13.5 "squidget" 18.0 "midget" 5 "didget" 10.2 8<------- cut here --------------------- Then run groff -Tps -p -ms barchart > barchart.ps and see what you get. (One advantage of doing it this kind of way is that it's much easier to add complications to the figure using PIC than it is by modifying PostScript such as Joost's). Best wishes, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Date: 24-Nov-99 Time: 13:34:47 ------------------------------ XFMail ------------------------------