Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
2  
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. –  rcollyer Jun 10 '13 at 19:59
    
@rcollyer So there's a built-in legend function in v9? That's nice! Thanks for the information. –  Leo Fang Jun 11 '13 at 5:08
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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