Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
498 views
in Technique[技术] by (71.8m points)

graphviz: left/right align nodes instead of centering?

Is there any way to get graphviz to left-align or right-align nodes in the same rank, instead of centering?

alt text

   digraph h {
     rankdir=LR;

     node [shape=record,height=.08,fontsize=11];

     elk[label="elk|I am an American Elk"];

     buffalo[label="buffalo|Just a buffalo|everywhere I go|people know the part I'm playing"];

     cow[label="cow|moo"];

     moose[label="Bullwinkle J. Moose|Hey Rocky, watch me pull a rabbit out of my hat!"];

     zoo [label="zoo|<p0>|<p1>|<p2>|<p3>"];

     zoo:p0 -> elk;
     zoo:p1 -> cow;
     zoo:p2 -> moose;
     zoo:p3 -> buffalo;
   }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It's nice to see someone working with such weighty data.

Here's one kludgey and unsatisfying way:

digraph h {
     rankdir=LR;
     node [shape=record,height=.08,fontsize=11];
     zoo [label="zoo|<p0>|<p1>|<p2>|<p3>"];

     node [width=3.5];
     elk[label="elkl|I am an American Elkl",];
     buffalo[label="buffalol|Just a buffalol|everywhere I gol|people know the part I'm playingl"];
     cow[label="cowl|mool"];
     moose[label="Bullwinkle J. Moosel|Hey Rocky, watch me pull a rabbit out of my hat!l"];

     zoo:p0->elk; zoo:p1 -> cow; zoo:p2 -> moose; zoo:p3 -> buffalo;
}

Give each box in that rank the same (empirically determined) width, then left-align the text using the weird l "left-aligned linebreak".


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...