data = {<|“ID” → “y1”, “x1” → 8.454545454545455, "x2" -> 6.,
“x3” → 46.36363636363637, "x4" -> 7.818181818181818,
“x5” → 17.15909090909091|>, <|"ID" -> "y2", "x1" -> 11.909090909090908, “x2” → 13.583333333333334, "x3" -> 12.818181818181818, “x4” → 11.909090909090908, "x5" -> 12.554924242424242|>, <|“ID” → “y3”,
“x1” → 9.454545454545455, "x2" -> 9.25,
“x3” → 9.909090909090908, "x4" -> 10.,
“x5” → 9.65340909090909|>, <|"ID" -> "y4", "x1" -> 34.666666666666664, “x2” → 32.45454545454545, "x3" -> 31.166666666666668, “x4” → 30.727272727272727, "x5" -> 32.25378787878788|>};
ytick = data[[All, 1]];
xtick = Rest@Keys@First@data;
MatrixPlot[Values@data[[All, 2 ;;]],FrameTicks → {{ytick, None}, {None, xtick}}]
MatrixPlot does not accept FrameTicks in text format.
How to plot the following figure?
Hi Ming-Chou
The ticks need to be paired with an index
ytickValues = Style[#, 22, Bold, Black] & /@ data[[All, 1]];
xtickValues = Style[#, 22, Bold, Black] & /@ Rest@Keys@First@data;
ytick = Transpose[{Range@Length@ytickValues, ytickValues}];
xtick = Transpose[{Range@Length@xtickValues, xtickValues}];
MatrixPlot[Values@data[[All, 2 ;;]], FrameTicks -> {{ytick, None}, {None, xtick}}]
I found that Spacings is not an option for MatrixPlot.
Is it possible to adjust the width of individual cells?
For example, the label string length in the last line is greater than the other line.
3Q~~
Not sure what you mean by
Is it possible to adjust the width of individual cells?
You can use the AspectRatio option to change the relative width and height of the cells.
You can use
Mesh -> All,
MeshStyle -> Directive[Thickness[.005], White],
to add a uniform spacing between cells.
Also not sure what you mean by
For example, the label string length in the last line is greater than
the other line
Do you mean that y4 is wider than y1? If so, you could try using a fixed-width font for the labels.