GridPlot
- To: mathgroup at smc.vnet.net
- Subject: [mg45795] GridPlot
- From: Selwyn Hollis <sh2.7183 at misspelled.erthlink.net>
- Date: Sun, 25 Jan 2004 03:04:49 -0500 (EST)
- References: <200401240536.AAA07423@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I've never much liked the way the GridLines option works in Plot. So
for my own amusement I decided to try something different, and it
turned into a nice exercise, I think. I thought some of you might be
interested in the result, which is the following (rough) function named
GridPlot. What it basically does is stretch automatically-generated
tickmarks out to form grid lines. (The GridColor option lets you can
change their color.)
GridPlot[f_, {x_, xmin_, xmax_}, opts___] :=
Module[{a, b, c, d, grph, fullgrph, gridcolor},
gridcolor = GridColor /. {opts} /.
{GridColor -> GrayLevel[0.85]};
fullgrph = FullGraphics[grph = Plot[f, {x, xmin, xmax},
DisplayFunction -> Identity,
Evaluate[DeleteCases[{opts},GridColor->_]]]];
{{a, b}, {c, d}} = PlotRange /. AbsoluteOptions[grph];
Show[ fullgrph /.{
{GrayLevel[0.], AbsoluteThickness[t_],
Line[{{u_,y1_},{u_,y2_}}]}/; (y2-y1<d-c) ->
{gridcolor, AbsoluteThickness[t], Line[{{u,c},{u,d}}]},
{GrayLevel[0.], AbsoluteThickness[t_],
Line[{{x1_,y_},{x2_,y_}}]}/; (x2-x1<b-a) ->
{gridcolor, AbsoluteThickness[t], Line[{{a,y},{b,y}}]}
},
grph, PlotRange -> {{a,b},{c,d}}, Axes -> True] ]
GridPlot[{1/x, Cos[x], Sin[x]}, {x, 0, 2Pi}]
Regards,
-----
Selwyn Hollis
http://www.math.armstrong.edu/faculty/hollis
(edit reply-to to reply)
- References:
- Any way to display vars internal to a function on interrupt?
- From: dont@agora.rdrop.com (Don Taylor)
- Any way to display vars internal to a function on interrupt?