Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: color legend

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110498] Re: color legend
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Mon, 21 Jun 2010 02:11:41 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

It you want it to do more, just tell it so.

Needs["PlotLegends`"]

arrayPlot[expr_, iterX_, iterY_] :=
 Module[
  {x = iterX[[1]], y = iterY[[1]],
   min, max, cons},
  cons = LessEqual @@ (#[[{2, 1, 3}]]) & /@
    {iterX, iterY};
  min = ToString[Round[
     NMinimize[{expr, cons},
        {x, y}][[1]] // Chop, 0.1]];
  max = ToString[Round[
     NMaximize[{expr, cons},
        {x, y}][[1]] // Chop, 0.1]];
  ShowLegend[
   ArrayPlot[
    Table[5./(1 + x^2 + y^2),
     iterX, iterY],
    Frame -> None,
    ColorFunction ->
     Function[{a},
      RGBColor[1 - a, 1 - a, 1 - a]]],
   {Function[{a},
     RGBColor[a, a, a]], 11, max, min,
    LegendPosition -> {1.1, -0.4}}]]

m = RandomInteger[{5, 25}]

10

arrayPlot[m/(1 + x^2 + y^2),
 {x, -5, 5}, {y, -5, 5}]


Bob Hanlon

---- "Kevin J. McCann" <kjm at KevinMcCann.com> wrote: 

=============
Bob,

The problem I have with this approach is that you have to give, in text, 
the min and max labels for the plot. This is clearly a place where 
errors can occur. It would be really great if all you had to do was to 
specify the min and max of the z-axis (color scale) and the legend 
automatically incorporated this.

Kevin

Bob Hanlon wrote:
> Needs["PlotLegends`"]
> 
> ShowLegend[
>  ArrayPlot[
>   Table[5./(1 + x^2 + y^2),
>    {x, -5, 5}, {y, -5, 5}],
>   Frame -> None,
>   ColorFunction ->
>    Function[{a},
>     RGBColor[1 - a, 1 - a, 1 - a]]],
>  {Function[{a},
>    RGBColor[a, a, a]],
>   11, " 5", " 0",
>   LegendPosition -> {1.1, -0.4}}]
> 
> 
> Bob Hanlon
> 
> ---- eric g <eric.phys at gmail.com> wrote: 
> 
> =============
> Hello Group,
> I want to add a color grayscale 
> (myColorFunction[x_]:=RGBColor[1-x,1-x,1-x]) legend this arrayplot, from 
> min (white) to max (dark) values.
> 
> ArrayPlot[Table[5./(1 + x^2 + y^2), {x, -5, 5}, {y, -5, 5}], Frame -> None]
> 
> best regards,
> eric
> 



  • Prev by Date: Re: Floating point exception when taking a reciprocal
  • Next by Date: Re: whats wrong with this code ?!
  • Previous by thread: Re: color legend
  • Next by thread: defining a function of functions