# ArrayPlot with logarithmic legend

I have a matrix that contains numbers in different orders of magnitude and I would like to plot it using ArrayPlot. For example purposes I create the matrix here, but actually it is not a function, so I cannot use DensityPlot.

someTable =
Table[Table[
PDF[ChiDistribution[s],
xx], {s, {.5, .75, 1.0, 1.5, 2.5}}], {xx, {10*^-3, 10*^-2,
0.1, 2.0, 5.0}}]


I compute the max and min values:

 {minran, maxran} = {Min[someTable], Max[someTable]}

(*Out: {7.73082*10^-7, 4.63842} *)

ArrayPlot[(randomTable), FrameStyle -> Opacity[0],
RotateLabel -> False, FrameTicksStyle -> Opacity[1],
ImageSize -> 800,
PlotLabel -> Style[#, 21, FontColor -> Black] &@("Some Matrix"),
ImageMargins -> 10, ColorFunction -> ColorData["Rainbow"],
ColorFunctionScaling -> True,
PlotLegends ->
Placed[BarLegend[{"Rainbow", {minran, maxran}},
LegendMarkerSize -> 500,
LabelStyle -> Directive[Black, 25, FontFamily -> "Times"]], {1.0,
0.5}]]


I get the following:

Changing to MatrixPlot and ColorFunctionScaling to False, I get:

I just want the different orders of magnitude to be visible with a nice color gradient. I have searched the documentation and S.E. and have found nothing similar. Just some answers for Density or ContourPlot.

I also would like to know why in the second case I see the FrameTicks Labels and in the first case they disappear.

as noted you could just plot Log[array].. but this is how to do it with ColorFunction

someTable =
Table[Table[
PDF[ChiDistribution[s],
xx], {s, {.5, .75, 1.0, 1.5, 2.5}}], {xx, {10*^-3, 10*^-2, 0.1,
2.0, 5.0}}]

ArrayPlot[(someTable), FrameStyle -> Opacity[0], RotateLabel -> False,
FrameTicksStyle -> Opacity[1], ImageSize -> 800,
PlotLabel -> Style[#, 21, FontColor -> Black] &@("Some Matrix"),
ImageMargins -> 10,
ColorFunction -> (ColorData["Rainbow"][
Rescale[Log[#], Log[MinMax[someTable]]]] &),
ColorFunctionScaling -> False,
PlotLegends ->
Placed[BarLegend[{(ColorData["Rainbow"][
Rescale[#, Log[MinMax[someTable]]]] &),
Log[MinMax[someTable]]}, LegendMarkerSize -> 500,
LabelStyle -> Directive[Black, 25, FontFamily -> "Times"]], {1.0,
0.5}]]


note the legend is showing Log value.

• Thanks this solved it for me! Since in my real applocation sometimes I find negative and positive entries, I am using signedLog=(Sign@# Log10@Abs@#)& instead of Log and it works fine. Oct 8, 2016 at 10:42
• It's a shame that the ticks cannot be overwritten with custom numbers or names as it can be done for the Ticks in Plot Oct 8, 2016 at 10:43