2
$\begingroup$

Suppose I have data like this

 data={{"300+", "300+", "300+", "Missing", "Missing", "Missing", "Missing", 
  "Missing", "Missing", "Missing"}, {"300+", "300+", "0-50", "300+", 
  "51-100", "0-50", "101-200", "0-50", "0-50", "Missing"}, {"300+", 
  "201-300", "0-50", "Missing", "Missing", "Missing", "Missing", 
  "Missing", "Missing", "300+"}, {"300+", "51-100", "0-50", "101-200",
   "0-50", "0-50", "0-50", "0-50", "0-50", "201-300"}, {"300+", 
  "201-300", "0-50", "Missing", "Missing", "Missing", "Missing", 
  "Missing", "Missing", "Missing"}, {"300+", "0-50", "0-50", "51-100",
   "0-50", "0-50", "0-50", "0-50", "0-50", "Missing"}, {"300+", 
  "51-100", "0-50", "Missing", "Missing", "Missing", "Missing", 
  "Missing", "Missing", "101-200"}, {"300+", "0-50", "0-50", "51-100",
   "0-50", "0-50", "0-50", "0-50", "0-50", "101-200"}, {"300+", 
  "101-200", "0-50", "Missing", "Missing", "Missing", "Missing", 
  "Missing", "Missing", "Missing"}, {"300+", "0-50", "0-50", "0-50", 
  "0-50", "0-50", "0-50", "Missing", "0-50", "Missing"}};

And I want to make a grid as follows:

ArrayPlot[
   data, ColorRules -> {
            "0-50" -> GrayLevel[0.8],
            "51-100" -> GrayLevel[0.6],
            "101-200" -> GrayLevel[0.4],
            "201-300" -> GrayLevel[0.2],
            "300+" -> GrayLevel[0.],
            "Missing" -> GrayLevel[1]
         },
   ColorFunction -> Automatic, FrameTicks -> Automatic, 
   PlotTheme -> "Detailed", Mesh -> True, Frame -> True, ImageSize -> Large
]

I want to place symbols in the corresponding boxes based on the following rule:

{"0-50" -> ♜, "51-100" -> ♞, "101-200" -> ♝, 
 "201-300" -> ♛, "300+" -> ♚, "Missing" -> ""}
$\endgroup$

1 Answer 1

3
$\begingroup$
labeling = {"0-50" -> ♜, "51-100" -> ♞,  "101-200" -> ♝, "201-300" -> ♛, 
      "300+" -> ♚, "Missing" -> ""};
epilog = Join @@ MapIndexed[Inset[#, #2 - 1/2]&, Transpose[Reverse@data /. labeling], {2}]
ArrayPlot[data, ColorRules -> {"0-50" -> GrayLevel[0.8], "51-100" -> GrayLevel[0.6], 
      "101-200" -> GrayLevel[0.3999999999999999], 
      "201-300" -> GrayLevel[0.19999999999999996`], 
      "300+" -> GrayLevel[0.], "Missing" -> GrayLevel[1]}, 
  ColorFunction -> Automatic, FrameTicks -> Automatic, 
  PlotTheme -> "Detailed", Mesh -> True, Frame -> True, 
  ImageSize -> Large, Epilog -> {Red, FontSize -> 20, epilog}]

enter image description here

$\endgroup$
2
  • $\begingroup$ I think the position is still incorrect it need to be rotated 90 degree clockwise. Can you please make the changes as i still don't fully understand how it works. $\endgroup$
    – user13892
    Commented Jun 6, 2018 at 13:22
  • $\begingroup$ @user13892, corrected the positions. $\endgroup$
    – kglr
    Commented Jun 6, 2018 at 13:31

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.