[metapost] Plotting step functions
Paul Menzel
paulepanter at users.sourceforge.net
Wed Dec 7 20:20:43 CET 2011
Dear MetaPost folks,
is there an easy way to define a path and let the lines in between
connected like a step function?
Is that already supported out of the box? Do you know existing macros
capable of doing that? The solution should be similar to drawing the
upper and lower Riemann sum in exercise 28 in the MAPS article Learning
MetaPost by Doing from André Heck [1].
The “brute force” method would be to make that manually.
\starttext
\startMPpage
draw (0,0)--(10,10)--(15,5)--(20,10);
draw (0,0)--(0,10)--(10,10)--(10,5)--(15,5)--(15,10)--(20,10) withcolor blue;
\stopMPpage
\stoptext
Having a command for that like -xy- or -yx- (depending what sides of the
rectangle to be used) would be comfortable though.
draw (0,0)-xy-(10,0)-xy-(10,10)-xy-(0,10)-xy-(0,0);
Please find some examples attached. The simple random walk example is
from Mojca Miklavec [2].
Thanks,
Paul
[1] http://staff.science.uva.nl/~heck/Courses/mptut.pdf
[2] http://www.ntg.nl/pipermail/ntg-context/2011/058528.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simple-random-walk.pdf
Type: application/pdf
Size: 26494 bytes
Desc: not available
URL: <http://tug.org/pipermail/metapost/attachments/20111207/b1f41932/attachment-0003.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simple-random-walk.tex
Type: text/x-tex
Size: 811 bytes
Desc: not available
URL: <http://tug.org/pipermail/metapost/attachments/20111207/b1f41932/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simple-random-walk--step.pdf
Type: application/pdf
Size: 27802 bytes
Desc: not available
URL: <http://tug.org/pipermail/metapost/attachments/20111207/b1f41932/attachment-0004.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simple-random-walk--step.tex
Type: text/x-tex
Size: 915 bytes
Desc: not available
URL: <http://tug.org/pipermail/metapost/attachments/20111207/b1f41932/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: step.pdf
Type: application/pdf
Size: 3059 bytes
Desc: not available
URL: <http://tug.org/pipermail/metapost/attachments/20111207/b1f41932/attachment-0005.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: step.tex
Type: text/x-tex
Size: 168 bytes
Desc: not available
URL: <http://tug.org/pipermail/metapost/attachments/20111207/b1f41932/attachment-0006.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/b1f41932/attachment-0007.bin>
More information about the metapost
mailing list