3
$\begingroup$

I have graphs created with Graph that display OK when shown individually, but when I put them in GraphicsRow, they get compressed and the vertex labels become illegible.

This displays fine - labels are readable

(* Create vertices  *)
vertices = {{}, {2}, {3}, {4}, {2, 3}, {2, 4}, {3, 4}, {2, 3, 4}};
(* Example edges *)
edges = {{2, 3} -> {2}, {2, 4} -> {4}};
(* Create labels with subscripts *)
labels = {
  {} -> "",
  {2} -> Placed[Subscript[i, 12], Above],
  {3} -> Placed[Subscript[i, 1], Above],
  {4} -> Placed[Subscript[i, 2], Above],
  {2, 3} -> Placed[Row[{Subscript[i, 12], Subscript[i, 1]}], Below],
  {2, 4} -> Placed[Row[{Subscript[i, 12], Subscript[i, 2]}], Below],
  {3, 4} -> Placed[Row[{Subscript[i, 1], Subscript[i, 2]}], Below],
  {2, 3, 4} -> Placed[Row[{Subscript[i, 12], Subscript[i, 1], Subscript[i, 2]}], Below]
};
(* Create graph with fixed size *)
g1 = Graph[vertices, edges,
  VertexLabels -> labels,
  VertexSize -> 0.4,
  GraphLayout -> {"LayeredDigraphEmbedding", "Orientation" -> Top},
  ImageSize -> {300, 300},
  ImagePadding -> {{40, 40}, {30, 30}}
]



(* Create three copies for demonstration *)
g2 = g1;
g3 = g1;
(* THIS IS THE PROBLEM: graphs get compressed, labels overlap *)
GraphicsRow[{g1, g2, g3}, Spacings -> 20]

How can I make GraphicsRow display each graph
without compression, so the labels remain readable?

$\endgroup$
3
  • 1
    $\begingroup$ Adding option ImageSize -> {3*300, 300} to the GraphicsRow? Since you have ImageSize -> {300, 300} for each of the three graphs. $\endgroup$ Commented yesterday
  • $\begingroup$ I cannot reproduce your problem on "14.2.1 for Mac OS X ARM (64-bit) (March 16, 2025)". $\endgroup$ Commented yesterday
  • $\begingroup$ Maybe Pane[GraphicsGrid[{{g1, g2, g3}}, ImageSize -> 1000], Full, ImageSizeAction -> "ShrinkToFit"]? I don't see how to get the graphs small enough without compression if three of them are wider than the window. The compression by Pane[] is different from that by GraphicsGrid[]. Or maybe you could use a wider window. I believe the window width is a factor here, but you haven't indicated what it is. Maybe it's not. $\endgroup$ Commented 13 hours ago

1 Answer 1

1
$\begingroup$

You could increse the y dimension of your separte graphics. However, it is simpler to use GraphicsGrid instead GraphicsRow and set ImageSize -> Scaled1:

GraphicsGrid[{{g1, g2, g3}}, ImageSize -> Scaled[1]]

enter image description here

$\endgroup$
3
  • $\begingroup$ ImageSize -> Scaled[1] can be used even with GraphicsRow. I do not see too much difference compared to GraphicsGrid. $\endgroup$ Commented 19 hours ago
  • $\begingroup$ Try it! You should not comment without verifying. $\endgroup$ Commented 14 hours ago
  • 1
    $\begingroup$ I commented because I have tried it. GraphicsGrid[{{g1, g2, g3}}, ImageSize -> Scaled[1]] and GraphicsRow[{g1, g2, g3}, ImageSize -> Scaled[1]] both produce visually the same output. At least for my version 14.3.0. Maybe it is version dependent... $\endgroup$ Commented 13 hours ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.