I'm trying to visualize some 'graphs' (i.e. the mathematical objects with nodes and edges) using GraphPlot[]. I am defining the nodes using objects such as

node[1] = Column[{"NGC", "1"}, Center]

and then setting the option VertexLabeling->True. I am also using VerticCoordinateRules with terms like

node[1]->{Automatic, 2}

Overall, I'm happy with my results except for the fact that the nodes are rendered overlapping one another (see the image below). I have tried messing around with DataRange option, but that doesn't seem to have any effect. Does anyone have any suggestions on how to fix this problem?

Here is an example.

graphNodes["Lys"] = {
 Column[{"AAA", "0.29"}, Center] -> Column[{"1CU", 11}, Center], 
 Column[{"AAA", "0.29"}, Center] -> Column[{"3UC", 14}, Center], 
 Column[{"AAA", "0.29"}, Center] -> Column[{"3UG", 9}, Center], 
 Column[{"AAA", "0.29"}, Center] -> Column[{"3UU", 7}, Center], 
 Column[{"AAA", "0.29"}, Center] -> Column[{"CUU", 14}, Center], 
 Column[{"AAA", "0.29"}, Center] -> Column[{"GUU", 10}, Center], 
 Column[{"AAA", "0.29"}, Center] -> Column[{"NGU", 4}, Center], 
 Column[{"AAA", "0.29"}, Center] -> Column[{"PAP", 2}, Center], 
 Column[{"AAG", "0   "}, Center] -> Column[{"3UU", 7}, Center], 
 Column[{"AAG", "0   "}, Center] -> Column[{"CAU", 5}, Center], 
 Column[{"AAG", "0   "}, Center] -> Column[{"CCU", 1}, Center], 
 Column[{"AAG", "0   "}, Center] -> Column[{"CUC", 2}, Center], 
 Column[{"AAG", "0   "}, Center] -> Column[{"CUU", 14}, Center], 
 Column[{"AAG", "0   "}, Center] -> Column[{"GUU", 10}, Center]};

nodeCoordinates["Lys"] = {Column[{"1CU", 11}, Center] -> {Automatic, 0}, 
 Column[{"3UC", 14}, Center] -> {Automatic, 0}, 
 Column[{"3UG", 9}, Center] -> {Automatic, 0}, 
 Column[{"3UU", 7}, Center] -> {Automatic, 4}, 
 Column[{"AAA", "0.29"}, Center] -> {Automatic, 2}, 
 Column[{"AAG", "0   "}, Center] -> {Automatic, 2}, 
 Column[{"CAU", 5}, Center] -> {Automatic, 0}, 
 Column[{"CCU", 1}, Center] -> {Automatic, 0}, 
 Column[{"CUC", 2}, Center] -> {Automatic, 0}, 
 Column[{"CUU", 14}, Center] -> {Automatic, 4}, 
 Column[{"GUU", 10}, Center] -> {Automatic, 0}, 
 Column[{"NGU", 4}, Center] -> {Automatic, 0}, 
 Column[{"PAP", 2}, Center] -> {Automatic, 0}};

GraphPlot[graphNodes[myAA], VertexLabeling -> True, 
 VertexCoordinateRules -> nodeCoordinates[myAA]]

And here's what I get, PlotGraph[] with overlapping nodes

  • $\begingroup$ Add ImageSize->... and adjust as needed, or calculate specific coordinates and use them... $\endgroup$
    – ciao
    May 28, 2015 at 23:25
  • $\begingroup$ Thanks for the suggestion @ciao, but I already tried using ImageSize and it generally doesn't work, especially since I am rendering multiple graphs. $\endgroup$ May 28, 2015 at 23:31

2 Answers 2


Either calculate correct / specific coordinates to effect a desired spacing, or use ImageSize option, e.g.

GraphPlot[graphNodes["Lys"], VertexLabeling -> True, 
 VertexCoordinateRules -> nodeCoordinates["Lys"], ImageSize -> 550]

enter image description here

  • $\begingroup$ Thanks @ciao, but one of the main reasons I am using GraphPlot[] is so I don't have to try and figure out the exact x-axis coordinates. I am doing this for 18 different amino acids and so I'd like a solution that doesn't involve me having to tweak each plot by setting different ImageSize options. $\endgroup$ May 28, 2015 at 23:46

Changing ImageSize with one number changes both the height and width of the figure. In order to preserve the height across differen datasets (which is in retrospect one aspect I want) I have found a reasonable solution that involves setting the Y aspect of ImageSize to a fixed value and the X aspect to a value based on the number of nodes at the bottom of the graph..

ImageSize -> {20*numNodes, 200}

I also realized one could set ImageSize ->numNodes and make AspectRatio->2/numNodes and get a similar effect.

My next goal is to figure out how to minimize the overlap in edges going to the bottom row (not an issue with "Lys" but a real problem with some other amino acids).

Thanks for your help @ciao.



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.