Question

I have a format which describes rectangles and connectivity between them.

for example: ( rect name width height location_coordinates )

rect b 10 10     0 0
rect f 10 10     0 10
rect k 20 10     0 20
rect c 10 10     10 0
rect g 10 10     10 10
rect e 10 10     20 0
rect d 10 10     20 10
rect a 10 10     20 20


edge b f 
edge b g
edge b c
edge f k
edge f g
edge g c
edge k g 
edge g a
edge g d 
edge g c
edge d e
edge d a
edge d e
edge d k

So for this I would like to get something like this:

enter image description here

Can I draw something similar using .dot/gnuplot format(or there are some other formats suitable for this case)?

I have looked over it, but cannot find a way how for example place rectangle in a specific location or how to connect rectangle centers.

Was it helpful?

Solution

Preprocess your data as follows, using awk or your favourite language

For each rectangle:

  • print x+y coordinates of its lower left corner
  • print x+y coordinates of its upper left corner
  • print x+y coordinates of its upper right corner
  • print x+y coordinates of its lower right corner
  • print x+y coordinates of its lower left corner
  • print a blank line (to suppress the connection between rectangles)

Plot this file with lines.

Write the edges into a second file

For each edge:

  • print x+y coordinates of midpoint of first rectangle
  • print x+y coordinates of midpoint of second rectangle
  • print blank line

Plot this file with lines.

Write the labels into a third file (x, y, label)

Plot them with labels.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top