How can I change the size of a specific subset of cells in a Grid
? I'm using the ItemSize
parameter for the ones I want to change, but it affects others, and I can't control the sizes separately.
More detail: I want to present a large matrix (48x48) with labels for each column and row. The way I'm doing it right now is with Grid
, by adding an extra row and column with the desired labels. However, since the entries are of varying lengths, I want to adjust the size of these Grid
cells so that they're all the same - but I want to leave the label cells unchanged.
Here is (a MWE of) my code to begin with:
labels = {"Long property name A", "Extremely long Property name B"};
Grid[Partition[Riffle[Join[
{Null},
Item[Rotate[#, -90 Degree], Alignment -> Bottom] & /@ labels,
{1, 3000, 5, 7000}],
Item[#, Alignment -> Right] & /@ labels, {4, -1, 3}], 3],
Frame -> All]
This is the result:
Now, I would like to change the size of the cells in the bottom right 4x4 submatrix, so that they all have the same size. I fix this by changing the table entry {1,3000,5,7000}
to:
Item[#, ItemSize -> 4] & /@ {1, 3000, 5, 7000}
But then this is the result:
I tried adding the ItemSize
parameter to the Item
s containing the labels, but the label text appears in a single line only if the cell is extremely wide, such as ItemSize->20
, which I don't want. So - how can I change the size of some of the cells without affecting the size of other cells?