Re: filling the area under a curve in gnuplot
On Tue, Jun 17, 2003 at 12:37:23AM +0200, martin f krafft wrote:
} also sprach Gregory Seidman <gss+debian@cs.brown.edu> [2003.06.16.0443 +0200]:
} > I don't know of a way of doing it from within gnuplot. If you want the
} > graph in some output format, however, I recommend writing it to EPS and
} > editing the PostScript by hand. From there you can use ghostscript to turn
} > it into whatever format you really want, if that isn't EPS.
}
} I was thinking about this, but it's not possible. The graphs are
} just too complex to devise a safe scripting method.
Hm. If you have a single data set then it shouldn't be too bad. If you have
multiple data sets then you would have difficulty making sense of all the
filled curves.
In looking at a simple example with only a single data set, the following
awk script does it, and should work for multiple data sets as well (YMMV):
#!/usr/bin/awk -f
BEGIN {
bottom = -1;
findbottom = -100;
begindata = -100;
pastgrid = 0;
addedfill = -101;
}
/^LTb$/ { findbottom = NR + 1; }
(NR==findbottom) { bottom = $2; }
(addedfill == begindata) && ( \
$3 == "Pnt" || \
$3 == "Dia" || \
$3 == "Pls" || \
$3 == "Box" || \
$3 == "Crs" || \
$3 == "TriU" || \
$3 == "Star" || \
$3 == "BoxF" || \
$3 == "TriUF" || \
$3 == "TriD" || \
$3 == "TriDF" || \
$3 == "DiaF" || \
$3 == "Pent" || \
$3 == "PentF" || \
$3 == "Circle" || \
$3 == "CircleF") {
addedfill = NR;
printf("currentpoint pop %d L\nfill\n", bottom);
}
/^stroke$/ {
if (addedfill==begindata) {
printf("currentpoint pop %d L\nfill\n", bottom);
}
next;
}
/^LT0$/ { pastgrid = 1; }
pastgrid && ($0 ~ /^(.*) Rshow$/) {
begindata = NR + 3;
addedfill = begindata;
}
(NR == begindata) {
printf("%d %d M\n%d %d L\n", $1, bottom, $1, $2);
next;
}
{ print }
} I am surprised that gnuplot can't do that...
Gnuplot is pretty simple. It really does very little. On the other hand, it
does what it does tolerably well.
} .''`. martin f. krafft <madduck@debian.org>
--Greg
Reply to: