0

How can I set the graph or image size in my generated pdf?

Using this code in org-mode:

 #+BEGIN_SRC dot :file hallo1_1_1.png 
 digraph hallo1_1_1 {
  A [shape = "circle",style=filled, fillcolor=yellow];
  }
  #+END_SRC

A giant page filling yellow pixeled circle is drawn. How can I set image size and resolution? Thank you.

Peter-TI
  • 91
  • 8
  • It's probably better to have dot generate the shape at a large size and then use the `attr_latex` mechanism in the answer to shrink it. That will avoid the pixelation that you observed. But you might have to increase the thickness of the boundary, which might become a bit ragged otherwise. Something like this should work: `A [shape = "circle", width=10, penwidth=2, style=filled, fillcolor=yellow];` – NickD Apr 11 '17 at 00:04
  • Got the resolution solution found :D. [Link -> StackOverFlow](http://stackoverflow.com/questions/1286813/how-do-i-set-the-resolution-when-converting-dot-files-graphviz-to-images) – Peter-TI Apr 11 '17 at 11:31
  • Got the resolution solution found. [Link -> StackOverFLow](http://stackoverflow.com/questions/1286813/how-do-i-set-the-resolution-when-converting-dot-files-graphviz-to-images) – Peter-TI Apr 11 '17 at 11:32

2 Answers2

2

You can always add specific LaTeX (or HTML) attributes to the result of a source block:

#+BEGIN_SRC dot :file hallo1_1_1.png 
 digraph hallo1_1_1 {
  A [shape = "circle",style=filled, fillcolor=yellow];
  }
#+END_SRC

#+attr_latex: :width 2cm
#+RESULTS:
[[file:hallo1_1_1.png]]

Documentation here.

Juancho
  • 7,207
  • 27
  • 31
  • Thanks a lot. I never would have got the idea for changing the png. Normaly I generetate the pdf by running "c-c e" on the whole org-file. In that case the #+RESULTS section would not show up. Thanks. Now I just added the #RESULT section to my "dot" snippet (If you know what I mean). Problem solved – Peter-TI Apr 11 '17 at 10:44
  • 1
    You don't need to add the `#RESULT` section manually; just `C-c C-c` on the source code block and it appears (and you can click on the image link to see it). – Juancho Apr 11 '17 at 12:01
0

You can set dpi option in header.

#+headers: :file file.gif :cmdline -Tgif -Gdpi=100
#+begin_src dot
 digraph g { 
...
}
#+end_src
vcmsxs
  • 99
  • 2
  • Unfortunately this didn't work. I was unable to set the resolution. – Peter-TI Apr 11 '17 at 11:27
  • Got the resolution solution found. [Link -> StackOverFLow][1] [1]: http://stackoverflow.com/questions/1286813/how-do-i-set-the-resolution-when-converting-dot-files-graphviz-to-images – Peter-TI Apr 11 '17 at 11:33