65

I tried

$ dot -Tpng rel_graph.gv > rel_graph.png

but the resulting image has a very low quality.

4 Answers 4

105

Use the dpi attribute.

Example:

graph G { 
  graph [ dpi = 300 ]; 
  /* The rest of your graph here. */ 
}
4
  • The negative side of this approach is that there is absolutely no anti-aliasing produced. With low resolution (like 72 dpi, for example) your output image will look very "dotted"
    – yegor256
    Feb 21, 2011 at 12:27
  • 4
    @yegor256 maybe they changed over the time, I see anti-aliasing on both 72 dpi and 300 dpi. Apr 18, 2013 at 8:34
  • 2
    @einpoklum yes it does
    – mgttlinger
    Jun 5, 2014 at 6:31
  • 29
    The equivalent -Gdpi=300 on the command line is also useful in some situations.
    – MvG
    Jul 7, 2015 at 20:58
60

dot -Tpng -Gdpi=300 foo.gv > foo110percent.png

Use option -Gdpi.

You can find more information here.

1
12

I find GraphViz draws nice Graphs but the resolution tends to be reasonably low, you could try outputting to SVG and then using some other image package to scale the image appropriately and then save to a pixel based format like PNG. This might give you better resolution but I've never tried it personally, I tend to mainly just create SVG files I can then view with a browser.

Just change the -T parameter to -Tsvg

dot -Tsvg rel_graph.gv > rel_graph.svg

There is some stuff in the Dot Guide http://www.graphviz.org/pdf/dotguide.pdf about scaling of Graphs but it's not very clear about how that affects resolution, you could also experiment with those settings and see if that improves things.

2
  • 1
    Saving the SVG data to a *.png file seems like a bad idea to me…
    – MvG
    Jul 7, 2015 at 20:59
  • @MvG Dumb typo on my part, think I copy pasted this from the OP question and didn't do a full png to svg change
    – RobV
    Jul 8, 2015 at 9:42
0

I think antialiasing is driver-dependent. For example, we hardcode cairo_font_options_set_antialias(options,CAIRO_ANTIALIAS_GRAY); but I don't see anything about explicit smoothing or antialiasing in other graphics primitives or any mention of antialiasing or smoothing in any other drivers.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.