I used the code GraphicsRow[{Text["1"], Graphics[Disk[]], Graphics[Disk[]]}]
to generate a row of graphics, but one of them is actually some text. I found that GraphicsRow
will try to put an "image frame" to make the text area have the same overall size as other graphics in this row. If the text is short, it has too much white margin on both sides; if the text is long, it adds a line break. My question is, is their a way I can adjust the "image frame size" of the text, so the text (or text grid) can fit in the row with a proper width?
Question:
How to reduce margins of text in GraphicsRow?
Adam: 3 days ago
Answer:
Lily: 3 days ago
There's an undocumented option "ManualSizes"
but you have to manually set all the ImageSizes
. Sometimes if the heights are different, strange things happen. You can use Rasterize[g, "RasterSize"]
to help figure out the ImageSizes
.
Also, Text
does not scale if the graphics are resized; in other words, if you drag one of the resize corners or edges of the graphics, you may cut off part of the text or introduce extra space. (This is true of Graphics[]
in general.)
textwidth[t_] := First@Rasterize[Style[Text[t], "Graphics"], "RasterSize"];
lbl = "1";
GraphicsRow[{
Graphics[Text[lbl], ImageSize -> {textwidth[lbl], 200}],
Graphics[Disk[], ImageSize -> {200, 200}],
Graphics[Disk[], ImageSize -> {200, 200}]},
"ManualSizes" -> True]
lbl = Style[StringJoin@CharacterRange["A", "Z"], Large];
GraphicsRow[{
Graphics[Text[lbl], ImageSize -> {textwidth[lbl], 360}],
Graphics[Disk[], ImageSize -> {360, 360}],
Graphics[Disk[], ImageSize -> {360, 360}]},
"ManualSizes" -> True]
- Physics questions and answers
- Chemistry questions and answers
- Math questions and answers
- Philosophy questions and answers
- Academic questions and answers
- Biology questions and answers
- History questions and answers
- Wolfram Mathematica questions and answers
- Astronomy questions and answers
- Economics questions and answers
- Computer Science questions and answers
- Earth Science questions and answers
- Bioinformatics questions and answers