Skip to main content

plotting - Combining Mesh and FrameLabel in ArrayPlot fails


I would like to create a labeled ArrayPlot with Mesh->True for example:


ArrayPlot[{{1, 0}, {0, 1}}, FrameLabel -> x, Mesh->True]

This does not show the FrameLabel, but


ArrayPlot[{{1, 0}, {0, 1}}, FrameLabel -> x]


does. I would guess it is a bug, but maybe there is some reason and I can work around it? I am on Mathematica 10.1.0.0 Linux.



Answer



The issue is that ArrayPlot[{{1, 0}, {0, 1}}, FrameLabel -> x, Mesh->True] renders the plot without a frame (hence no framelabel):


ArrayPlot[{{1, 0}, {0, 1}}, FrameLabel -> x, Mesh->True]

Mathematica graphics


What is happening can be seen in a simpler example without FrameLabel:


ArrayPlot[{{1, 0}, {0, 1}}]


Mathematica graphics


Options[ArrayPlot[{{1, 0}, {0, 1}}], Frame]


{Frame -> Automatic}



Somehow adding the option Mesh->True sets the option Frame to False:


 ArrayPlot[{{1, 0}, {0, 1}}, Mesh -> True]

Mathematica graphics



Options[ArrayPlot[{{1, 0}, {0, 1}}, Mesh -> True], Frame]


{Frame -> False}



The fix is to add the option Frame->True:


ArrayPlot[{{1, 0}, {0, 1}}, Frame -> True, FrameLabel -> x, Mesh -> True]

Mathematica graphics


Comments