Re: contour-plot & ascii-art
- To: mathgroup at smc.vnet.net
- Subject: [mg23746] Re: [mg23691] contour-plot & ascii-art
- From: Wolf Hartmut <hwolf at debis.com>
- Date: Mon, 5 Jun 2000 01:09:40 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
-----Urspr\174ngliche Nachricht-----
Von: Nicola Attico [SMTP:attico at peg2.difi.unipi.it]
Someone can explain me how to create a
shaded contour plot together with a bar where the
various gray-levels have a numerical value
specified (a sort of thermometer).
This is a very usual way of specifying the
``z-value'' associated with a gray-level.
I'm sure Mathematica has this feature.
Nicola,
to make up a sample:
f[x_, y_] :=
With[{a = y Exp[-(y^2 - 1)], b = 1 + Exp[-y^2]/2},
a With[{x1 = 0.776887 b x},
2 - ((-0.5 - x1)(0.5 - x1))^2/0.5^4 ] +
(1 - a) (1 - (b x)^4 ) /; (b x)^2 < 1 && y > 0]
f[x_, y_] := With[{b = 1 + Exp[-y^2]/2}, (1 - (b x)^4 )
/; (b x)^2 < 1 ]
f[__] = 0;
p = DensityPlot[f[x, y], {x, -1.3, 1.3}, {y, -2.5, 2},
ColorFunction -> (GrayLevel[1 - #] &), PlotPoints -> 30,
DisplayFunction -> Identity]
(* Never mind what f[x,y] is. *)
<< Graphics`Legend`
max = 1`3 + Sqrt[E/2]
ShowLegend[p, {GrayLevel, 6, ToString[max], "0.",
LegendPosition -> {1.1, -.4}}]
Oh, looking at the subject, sorry, if you prefer the ContourPlot, just
replace p -> ContourGraphics[p] in the preceeding expression.
-- Hartmut Wolf