title: Haskell Diagrams Graphviz Gtk Display alignment and scaling
body: <p>I want to display a graph layed out by <code>graphviz</code> (via <code>Data.GraphViz</code>) in a Gtk window. The code I have does not automatically center the graph or size the diagram. I have setup a github repo with an example (see <code>src/Main.hs</code> at <a href="https://github.com/avras/diagrams-gtk-graphviz-example" rel="nofollow noreferrer">https://github.com/avras/diagrams-gtk-graphviz-example</a>. I get the following output.</p>
  
  <p><a href="https://i.stack.imgur.com/kWnUZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kWnUZ.png" alt="enter image description here"></a></p>
  
  <p>If I try showing a circle of radius one, I get the following output (which is expected). The code for this example is at <code>src/Circle.hs</code> in the same github repository. <code>Main.hs</code> and <code>Circle.hs</code> differ only in the diagram which is rendered (afaict).</p>
  
  <p><a href="https://i.stack.imgur.com/5QoDZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5QoDZ.png" alt="enter image description here"></a></p>
  
  <p><strong>How can I get the graph to be centered in the window with the right width automatically calculated?</strong> </p>
  
  <p>I had to play around with the argument to <code>mkWidth</code> to get this picture. Also without setting <code>lw 0.005</code> the result was the following. The line width seems to be very large.</p>
  
  <p><a href="https://i.stack.imgur.com/S6bh8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S6bh8.png" alt="enter image description here"></a></p>
  
  <p><strong>EDIT</strong> Here is the result after the fix suggested by Joachim Breitner.
  <a href="https://i.stack.imgur.com/s0zJJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s0zJJ.png" alt="enter image description here"></a></p>