[metapost] [solved] Plotting step functions

Paul Menzel paulepanter at users.sourceforge.net
Wed Dec 7 21:07:22 CET 2011


Am Mittwoch, den 07.12.2011, 13:56 -0600 schrieb Troy Henderson:
> How about something like this:
> 
> vardef stepfunc primary p =
> 	save q;
> 	path q;
> 	q:=(point 0 of p) for n=1 upto length p: --(xpart point (n-1) of p,ypart point n of p)--(point n of p) endfor;
> 	q
> enddef;
> 
> and then use it in the following way:
> 
> path p;
> p:=(0,0)--(10,10)--(15,5)--(20,10);
> draw p;
> draw stepfunc p withcolor blue;

Very nice! It looks like exactly what I needed.


Thank you very much,

Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: step.pdf
Type: application/pdf
Size: 3328 bytes
Desc: not available
URL: <http://tug.org/pipermail/metapost/attachments/20111207/813eba0d/attachment.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: step.tex
Type: text/x-tex
Size: 490 bytes
Desc: not available
URL: <http://tug.org/pipermail/metapost/attachments/20111207/813eba0d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://tug.org/pipermail/metapost/attachments/20111207/813eba0d/attachment-0001.bin>


More information about the metapost mailing list