![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
David Arnold wrote:
Hi,
I confess I got some earlier advice on this issue, but I've never been able to apply it to find a resolution. In the buffer that follows, I define a clipping box:
% clipping path path cpath; cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle; cpath:=cpath scaled 1u;
A function is created and scaled:
% scale and draw graph P:=P scaled u; draw P withcolor blue;
The picture is clipped and saved:
% clip and save current picture picture pic; clip currentpicture to cpath; pic:=currentpicture;
Then it is redrawn later.
% redraw line draw pic;
Unfortunately, even though this works, mathematicians really want arrows at each end of the graph. Easy enough to do with drawdblarrow P withcolor blue, but the arrows then get clipped. What I really need is to adapt the code below so that my function is clipped to the boundary box, but then redrawn with arrows at each end of it. If anyone can adjust my code to do that, it would be much appreciated, and it would break down a barrier I've faced for years with metapost coding.
Note that I've tried some stuff with cutbefore and cutafter with some success. But I should remark that the code below is generated by a perl script and some special coding we've set up to generate these graphics on the fly for student quizzes. This is not a situation where I can tweak an individual plot or two. Rather, our script might generate 100 sets of the code below, all with different parameters. So this magnifies the problem.
as you sat, the basics are in: P := (P cutbefore cpath) ; P := (P cutafter cpath) ; drawdblarrow P withcolor green; it should not be too hard for a mathematician to make sure that this works ok; i think that as long as one makes sure that the directions are right (do a reverse P if needed) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------