MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Expressing values in the legend in terms of original data

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92573] Re: Expressing values in the legend in terms of original data
  • From: "sjoerd.c.devries at gmail.com" <sjoerd.c.devries at gmail.com>
  • Date: Mon, 6 Oct 2008 04:13:53 -0400 (EDT)
  • References: <gbvlva$bdf$1@smc.vnet.net>

In addition to my previous reply I should have taken the automatic
ranging of ContourPlot into account as it scales values to give a 0..1
range.

So, if you want to make sure the legend maps GrayLevels 0..1 to the
-2..2 range (in case the ends of this range are not within the plot
region) you have to adjust the scaling of ContourPlot accordingly:

contourPlotFun =
  ContourPlot[
   2 Sin[x y], {x, -\[Pi]/2, \[Pi]/2}, {y, -\[Pi]/2, \[Pi]/2},
   ColorFunctionScaling -> False,
   ColorFunction -> (GrayLevel[1 - ((# + 2)/4)] &)];

ShowLegend[contourPlotFun, {GrayLevel[1 - #] &, 10, " 2", "-2",
  LegendPosition -> {1.1, -.4}, LegendShadow -> None}]


Cheers -- Sjoerd


On Oct 1, 1:12 pm, er <erwann.rog... at gmail.com> wrote:
> Hi,
>
> Considering
>
> contourPlotFun=
>     ContourPlot[2 Sin[x y],{x,-\[Pi]/2,\[Pi]/2},{y,-\[Pi]/2,\[Pi]/2},
>       DisplayFunction\[Rule]Identity];
>
> ShowLegend[
>     contourPlotFun,{GrayLevel[1-#]&,10," 1","-1",
>       LegendPosition\[Rule]{1.1,-.4}}];
>
> The legend here is misleading, because the min and max values are -2
> and 2, respectively, not -1 and 1. So how can I modify the input to
> ShowLegend to reflect that?
>
> Thanks!



  • Prev by Date: Re: NDSolve and error
  • Next by Date: Re: Expressing values in the legend in terms of original data
  • Previous by thread: Re: Expressing values in the legend in terms of original data
  • Next by thread: Re: Expressing values in the legend in terms of original data