in reply to Graphing non uniform data as bar charts
There is one more glitch however - Chart::Plot does not correctly account for the plotting offset caused by insertion of the graph title, so you cannot use that option if you want this to work. You may just superimpose the graph title text via the GD object, I didn't bother for this trial. I hope this helps!
#!/usr/bin/perl -w use strict; use Chart::Plot; my $img = Chart::Plot->new(); my @xdataset = qw(791.312 809.298 825.259 842.510 855.028 861.120 870.554 870.977 877.036 893.436 1060.006 1066.030 1081.967 1270.989 2211.105 2225.178 2239.090); my @ydataset = qw(1383.8 1863.9 1247 2191.4 2101.2 624.96 552.55 1050.3 690.71 538.11 705.84 566.41 397.68 133.13 158.5 91.587 82.42); $img->setGraphOptions ( 'horGraphOffset' => 75, 'vertGraphOffset' => 100, 'horAxisLabel' => 'mass/charge', 'vertAxisLabel' => 'intensity', ); # plots nothing visible, but sets up axis scales: $img->setData (\@xdataset, \@ydataset, 'nolines nopoints'); # now draw some vertical bars: my $gdobj = $img->getGDobject; my $blue = $gdobj->colorAllocate(0,0,255); for my $i (0..$#xdataset) { $gdobj->line($img->data2pxl($xdataset[$i],0), $img->data2pxl($xdataset[$i], $ydataset[$i]), $blue); } open (WR,'>plot.png') or die ("Failed to write file: $!"); binmode WR; # for DOSish platforms print WR $img->draw(); close WR;
--
I'd like to be able to assign to an luser
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Graphing non uniform data as bar charts
by lostcause (Monk) on Aug 15, 2001 at 23:19 UTC |