0
$\begingroup$

I use Hue to color ArrayPlot:

Needs["PlotLegends`"]
GraphicsRow[{
 ArrayPlot[gridmatrixpair, Mesh -> False, 
   ColorFunction -> (
    Which[2.0 < #[[1]] < 4.9 && 3*10^8 > #[[2]] > 1*10^6, 
          Hue[(#[[2]] - 1*10^6)*3.344*10^-9],
          True, White
         ] &), 
   ColorFunctionScaling -> False, AspectRatio -> 2/7, 
   FrameLabel -> {y, x}
 ], 
 Graphics[
   Legend[ColorData["Rainbow"][1 - #1] &, 10, "10^6", "10^8", 
    LegendShadow -> None, LegendLabel -> "Power (a.u.)"]]
}]

enter image description here

But as you see the colors in ArrayPlot are brighter than the rainbow colors for the legend. I did not find another ColorData object with brighter colors. What can I do, the scale is changing on and on for different notebooks, so the scale spectrum should be part of the Legend object.

$\endgroup$
2
  • 2
    $\begingroup$ Ignoring for the moment that the PlotLegends` package has been superseded by built in functionality in v9, you are not using the same color distribution in ArrayPlot as you are in Legend. Have you actually tried using Hue in Legend? You may have to Rescale it, but that shouldn't be an issue. Truthfully, though, if you are using v9, use the PlotLegends option, it is wholly superior to the PlotLegends` package. $\endgroup$
    – rcollyer
    Commented Jun 10, 2013 at 19:59
  • $\begingroup$ @rcollyer So there's a built-in legend function in v9? That's nice! Thanks for the information. $\endgroup$
    – Leo Fang
    Commented Jun 11, 2013 at 5:08

1 Answer 1

3
$\begingroup$

You need to use the same colour distribution in ArrayPlot as you are in Legend (or the other way around):

Needs["PlotLegends`"]
GraphicsRow[{
 ArrayPlot[gridmatrixpair, Mesh -> False, 
   ColorFunction -> (
    Which[2.0 < #[[1]] < 4.9 && 3*10^8 > #[[2]] > 1*10^6, 
          Hue[(#[[2]] - 1*10^6)*3.344*10^-9],
          True, White
         ] &), 
   ColorFunctionScaling -> False, AspectRatio -> 2/7, 
   FrameLabel -> {y, x}
 ], 
 Graphics[
   Legend[ColorData["Hue"][1 - #1] &, 10, "10^6", "10^8", 
    LegendShadow -> None, LegendLabel -> "Power (a.u.)"]]
}]

Alternatively, for v9, use the PlotLegends option which is much superior to the PlotLegends package.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.