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: [mg92572] 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:42 -0400 (EDT)
  • References: <gbvlva$bdf$1@smc.vnet.net>

Er,

In my version of Mathematica (6.03 WinXP) the ContourPlot is in color
by default. It doesn't make sense to add a grayscale legend. So either
you color the legend or you add a greyscale ColorFunction to the
ContourPlot:

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

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

The legend doesn't adapt to the range of your plot. You have to
provide the range yourself. In the expression above I put in 2 and -2
and that does the trick.

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: Expressing values in the legend in terms of original data
  • Next by Date: Re: could not get Simplified form
  • Previous by thread: Re: Expressing values in the legend in terms of original data
  • Next by thread: Re: Avoiding Null output marker from a function