[7] in mathematical software users group
(MAPLEV) 2d point-plotting with a point instead of a plus
daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Fri Mar 6 15:31:40 1992
To: msug@MIT.EDU
Date: Fri, 06 Mar 92 15:30:27 EST
From: Reid M. Pinchback <reidmp@Athena.MIT.EDU>
For those of us who wish Maple V would let us have a bit more control
over how 2D plots look, here is some code that will plot points as
dots instead of +'s, and with your choice of colour.
The idea of the code is that it builds a Maple "plot" structure and
fools Maple into thinking that it is plotting lines (which are plotted
with pixels) instead of points (which are plotted with +'s). Since
the lines start and end at the same point, they show up as a single
pixel on the screen.
To plot the points [1,1], [2,2], in cyan colour, for instance, you
just do:
pplot2d( [ [1,1],[2,2] ], CYAN );
I tried using "display" to plot groups of points generated by pplot2d
to see if the groups maintained colour, but it seems to reassign
colours to all the points randomly... but at least the existing code
is reasonably short and and not too hard to understand.
Note that since the points are only once pixel in size, they are quite
small, and faint with some colour choices. It would be an interesting
extension to have the code plot small circles, but unfortunately they
would scale larger or smaller according to the window size.
I tested the code on Unix machines running X11R4 mono and colour, but
I don't know if it will work on other platforms. I'd be interested
to hear how it performs in other environments, and whether or not
other Maple users have tried to decode Maples PLOT and PLOT3D structures.
Reid M. Pinchback
Faculty Liaison
Academic Computing Services, MIT
-------- 8< ---- CUT HERE ---- 8< -----------------------------------------
`type/plotcolour` := proc(x)
member(x,convert('_COLOURARRAY',set));
# X11R4 colours = {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE}
end;
`type/pairn` := [ numeric, numeric ];
pplot2d := proc(P,colour)
local curves, i;
if nargs<>2 then
ERROR(`pplot2d: incorrect number of arguments, need 2 arguments`);
elif not type(P,list(pairn)) then
ERROR(`pplot2d: incorrect type for first argument, need list(pairn)`);
elif not type(colour,plotcolour) then
ERROR(`incorrect type for second argument, need plotcolour`);
else
curves := 'CURVE(
FUNCTION(LIST(P[i])),
colour,
LINE,
[ op(P[i]), op(P[i]) ]
)' $ i = 1 .. nops(P);
PLOT(
AXIS(HORIZONTAL, SCALE(4,LINEAR,NUMBER)),
AXIS(VERTICAL, SCALE(4,LINEAR,NUMBER)),
curves
);
fi;
end;
-------- 8< ---- CUT HERE ---- 8< -----------------------------------------