0
$\begingroup$

I have the following code which yields the figure attached:

MatrixPlot[{{1, 4, 8}, {2, 5, 7}}, 
 FrameStyle -> Directive[Blue, Thickness[0.019]], 
   FrameLabel -> {{HoldForm[left], 
    HoldForm[right]}, {HoldForm[bottom], HoldForm[top]}}, 
   PlotLabel -> HoldForm[Matrix*Plot], 
 LabelStyle -> {FontFamily -> "Aharoni", 24, GrayLevel[0], Bold}]

How do I perform the following:

1) Increase the spacing between the words "Matrix Plot" and "top"

2) Label each pixel as "(1,1), (1,2), (1,3)..." etc

enter image description here

$\endgroup$
  • $\begingroup$ Not sure why you chose not to use strings: MatrixPlot[{{1, 4, 8}, {2, 5, 7}}, FrameLabel -> {{"Left", "Right"}, {"Bottom", "Top"}}, FrameStyle -> Directive[Blue, Thickness[0.019]], PlotLabel -> Style["Matrix Plot\n", Blue]]. $\endgroup$ – J. M. will be back soon Oct 20 '15 at 23:58
  • $\begingroup$ I should have used strings, thanks. The use of Style["Matrix Plot\n",Blue] fixes the first part...increases distance between the two words. How about inserting labels at centre of each pixel? $\endgroup$ – thils Oct 21 '15 at 1:59
  • $\begingroup$ You shoul be able to adapt this answer to your situation. $\endgroup$ – J. M. will be back soon Oct 21 '15 at 2:28
1
$\begingroup$

Based on the suggestions provided by J.M, I have employed the following code to get the desired output. So credit rightly belong to J.M

 MatrixPlot[{{1, 4, 8}, {2, 5, 7}}, 
 FrameLabel -> {{"Bottom", "Top"}, {"Left", "Right"}}, 
   FrameStyle -> Directive[Blue, Thickness[0.019]], 
 LabelStyle -> {FontFamily -> "Aharoni", 30, GrayLevel[0], Bold}, 
   PlotLabel -> Style["Matrix Plot\n", Red],  
 Epilog -> {Blue, 
   MapIndexed[
    Text[Style[#1, Red, Bold, Italic, 22], Reverse[#2 - 1/2], 
      Background -> Yellow] & , 
         Reverse[
     Array[StringForm["(`1`,`2`)", ##1] & , {2, 3}]], {2}]}, 
   Mesh -> True]

Have incorporated later suggestions in this edited version

enter image description here

$\endgroup$
  • $\begingroup$ You can use Style[] within Text[] for changing colors and font sizes. As for labels, try this: MapIndexed[Text[Style[#1, Blue], Reverse[#2 - 1/2]] &, Reverse[Array[StringForm["(`1`,`2`)", ##] &, {2, 3}]], {2}] $\endgroup$ – J. M. will be back soon Oct 21 '15 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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