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$
3
  • $\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$ Oct 20, 2015 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, 2015 at 1:59
  • $\begingroup$ You shoul be able to adapt this answer to your situation. $\endgroup$ Oct 21, 2015 at 2:28

1 Answer 1

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$
1
  • $\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$ Oct 21, 2015 at 4:23

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.