emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* best ways to generate simple diagrams?
@ 2019-05-06 18:17 Matt Price
  2019-05-06 19:12 ` ckelty ckelty
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Matt Price @ 2019-05-06 18:17 UTC (permalink / raw)
  To: Org Mode


[-- Attachment #1.1: Type: text/plain, Size: 918 bytes --]

So, I'm finding more and more that I want to include simple diagrams in my
course materials. At present I am generating them as svg's using Inkscape,
but that feels really tiresome to me. I would much rather make them
programmatically, preferably including the source code as an org-mode block.

I thought ditaa would be the tool for this, but I cannot figure out how to
do this work efficiently in ditaa.  So for instance, I have this simple svg
file (attached). It consists of two text-containing  symmetrical rectangles
separated by a bit of whitespace and connected by two curved arrows (one
pointing from each of the rectangles to the other).

Trying to replicate this in ditaa did not prove easy.  Editing feels
extremely labourious.  Am I missing something?  Is there a really good
tutorial somehwere that I'm just not finding? Or is there maybe another
tool I should be using instead?

Thanks as always,

Matt

[-- Attachment #1.2: Type: text/html, Size: 1105 bytes --]

[-- Attachment #2: hum-cs-interface.svg --]
[-- Type: image/svg+xml, Size: 7946 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: best ways to generate simple diagrams?
  2019-05-06 18:17 best ways to generate simple diagrams? Matt Price
@ 2019-05-06 19:12 ` ckelty ckelty
  2019-05-06 20:08 ` Heinz Tuechler
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: ckelty ckelty @ 2019-05-06 19:12 UTC (permalink / raw)
  To: emacs-orgmode


Matt,

Did you already decide against graphviz?  Admittedly it is only 
graphs and not "diagrams"... but it's very powerful and there is 
art in using a simple tool to make your life complex :)


#+BEGIN_SRC dot :file test-dot.png  :exports results
digraph D {

  Humanities -> {"Computing Tools and Methodologies"}
  {"Computing Tools and Methodologies"} -> Humanities 

}
#+END_SRC

#+RESULTS:
[[file:test-dot.png]]


ck



Matt Price <moptop99@gmail.com> writes:

> So, I'm finding more and more that I want to include simple 
> diagrams in my
> course materials. At present I am generating them as svg's using 
> Inkscape,
> but that feels really tiresome to me. I would much rather make 
> them
> programmatically, preferably including the source code as an 
> org-mode block.
>
> I thought ditaa would be the tool for this, but I cannot figure 
> out how to
> do this work efficiently in ditaa.  So for instance, I have this 
> simple svg
> file (attached). It consists of two text-containing  symmetrical 
> rectangles
> separated by a bit of whitespace and connected by two curved 
> arrows (one
> pointing from each of the rectangles to the other).
>
> Trying to replicate this in ditaa did not prove easy.  Editing 
> feels
> extremely labourious.  Am I missing something?  Is there a 
> really good
> tutorial somehwere that I'm just not finding? Or is there maybe 
> another
> tool I should be using instead?
>
> Thanks as always,
>
> Matt

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: best ways to generate simple diagrams?
  2019-05-06 18:17 best ways to generate simple diagrams? Matt Price
  2019-05-06 19:12 ` ckelty ckelty
@ 2019-05-06 20:08 ` Heinz Tuechler
  2019-05-07 11:25 ` Fraga, Eric
  2019-05-08  4:06 ` Marcin Borkowski
  3 siblings, 0 replies; 10+ messages in thread
From: Heinz Tuechler @ 2019-05-06 20:08 UTC (permalink / raw)
  To: emacs-orgmode

Matt Price wrote/hat geschrieben on/am 06.05.2019 19:17:
> So, I'm finding more and more that I want to include simple diagrams in my
> course materials. At present I am generating them as svg's using Inkscape,
> but that feels really tiresome to me. I would much rather make them
> programmatically, preferably including the source code as an org-mode block.
>
> I thought ditaa would be the tool for this, but I cannot figure out how to
> do this work efficiently in ditaa.  So for instance, I have this simple svg
> file (attached). It consists of two text-containing  symmetrical rectangles
> separated by a bit of whitespace and connected by two curved arrows (one
> pointing from each of the rectangles to the other).
>
> Trying to replicate this in ditaa did not prove easy.  Editing feels
> extremely labourious.  Am I missing something?  Is there a really good
> tutorial somehwere that I'm just not finding? Or is there maybe another
> tool I should be using instead?
>
> Thanks as always,
>
> Matt
>
Maybe plantuml (http://plantuml.com/en/) is useful, e.g.


#+begin_src plantuml :file hum-cs-interface-test.svg
skinparam ArrowColor Blue
node "Humanities" as H #DeepSkyBlue
node "Computing\n Tools and\n Methodologies" as N #DeepSkyBlue

N =l=> H
H =r=> N

#+end_src

best regards,

Heinz

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: best ways to generate simple diagrams?
  2019-05-06 18:17 best ways to generate simple diagrams? Matt Price
  2019-05-06 19:12 ` ckelty ckelty
  2019-05-06 20:08 ` Heinz Tuechler
@ 2019-05-07 11:25 ` Fraga, Eric
  2019-05-07 17:22   ` Matt Price
  2019-05-08  4:06 ` Marcin Borkowski
  3 siblings, 1 reply; 10+ messages in thread
From: Fraga, Eric @ 2019-05-07 11:25 UTC (permalink / raw)
  To: Matt Price; +Cc: Org Mode

On Monday,  6 May 2019 at 14:17, Matt Price wrote:
> So, I'm finding more and more that I want to include simple diagrams in my
> course materials. At present I am generating them as svg's using Inkscape,
> but that feels really tiresome to me. I would much rather make them
> programmatically, preferably including the source code as an org-mode block.

You have had recommendations for graphviz (dot etc.) and plantuml
already.  Those are very good suggestions and I use them all the
time.  For more general drawings, and given that you want something
programmatic, I would also suggest tikz (in LaTeX) as it's very powerful
(but then harder to do some simple things that graphiz/plantuml will do
very easily).

#+begin_export latex
\begin{tikzpicture}[node distance=4cm,minimum size=2cm]
  \node[draw,fill=blue!20!white] (humanities) {Humanities};
  \node[draw,fill=blue!20!white] (tools) [right of=humanities] {\parbox{3cm}{Computing \\ Tools and \\ Methodologies}}
  edge [->,out=270,in=270,very thick,red] (humanities)
  edge [<-,out=90,in=90,very thick,red] (humanities);
\end{tikzpicture}
#+end_export

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.2.3-327-g3375f0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: best ways to generate simple diagrams?
  2019-05-07 11:25 ` Fraga, Eric
@ 2019-05-07 17:22   ` Matt Price
  2019-05-07 17:52     ` Fraga, Eric
  0 siblings, 1 reply; 10+ messages in thread
From: Matt Price @ 2019-05-07 17:22 UTC (permalink / raw)
  Cc: Org Mode

[-- Attachment #1: Type: text/plain, Size: 2318 bytes --]

These are all great.  I am struggling to some extent through the docs for
all these tools.  Eric, for the most part I'm very happy with graphviz &
plantufml but I would be interested in trying latex as well.  Since I'm
mostly exporting to html and its derivatives (markdown mostly), I don't
think epxort blocks work for my purposes.  I thought that a latex src block
with :exports results would work, but rather than a rendered graph I end up
with a .png of the latex instructions themselves. Here's what I am trying:

#+begin_src latex :exports results :file latex-dh.png
\begin{tikzpicture}[node distance=4cm,minimum size=2cm]
  \node[draw,fill=blue!20!white] (humanities) {Humanities};
  \node[draw,fill=blue!20!white] (tools) [right of=humanities]
{\parbox{3cm}{Computing \\ Tools and \\ Methodologies}}
  edge [->,out=270,in=270,very thick,red] (humanities)
  edge [<-,out=90,in=90,very thick,red] (humanities);
\end{tikzpicture}
#+end_src

Can you see my error and/or reproduce the issue? Thanks all of you!


On Tue, May 7, 2019 at 7:25 AM Fraga, Eric <e.fraga@ucl.ac.uk> wrote:

> On Monday,  6 May 2019 at 14:17, Matt Price wrote:
> > So, I'm finding more and more that I want to include simple diagrams in
> my
> > course materials. At present I am generating them as svg's using
> Inkscape,
> > but that feels really tiresome to me. I would much rather make them
> > programmatically, preferably including the source code as an org-mode
> block.
>
> You have had recommendations for graphviz (dot etc.) and plantuml
> already.  Those are very good suggestions and I use them all the
> time.  For more general drawings, and given that you want something
> programmatic, I would also suggest tikz (in LaTeX) as it's very powerful
> (but then harder to do some simple things that graphiz/plantuml will do
> very easily).
>
> #+begin_export latex
> \begin{tikzpicture}[node distance=4cm,minimum size=2cm]
>   \node[draw,fill=blue!20!white] (humanities) {Humanities};
>   \node[draw,fill=blue!20!white] (tools) [right of=humanities]
> {\parbox{3cm}{Computing \\ Tools and \\ Methodologies}}
>   edge [->,out=270,in=270,very thick,red] (humanities)
>   edge [<-,out=90,in=90,very thick,red] (humanities);
> \end{tikzpicture}
> #+end_export
>
> --
> Eric S Fraga via Emacs 27.0.50, Org release_9.2.3-327-g3375f0
>

[-- Attachment #2: Type: text/html, Size: 2868 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: best ways to generate simple diagrams?
  2019-05-07 17:22   ` Matt Price
@ 2019-05-07 17:52     ` Fraga, Eric
  2019-05-07 20:36       ` Matt Price
  0 siblings, 1 reply; 10+ messages in thread
From: Fraga, Eric @ 2019-05-07 17:52 UTC (permalink / raw)
  To: Matt Price; +Cc: Org Mode

On Tuesday,  7 May 2019 at 13:22, Matt Price wrote:
> I thought that a latex src block with :exports results would work, but
> rather than a rendered graph I end up with a .png of the latex
> instructions themselves. Here's what I am trying:

It should work.  Try with the following header settings:

#+header: :exports results
#+header: :results file raw
#+header: :file image.png
#+header: :fit yes
#+begin_src latex
  \begin{tikzpicture}[node distance=4cm,minimum size=2cm]
    \node[draw,fill=blue!20!white] (humanities) {Humanities};
    \node[draw,fill=blue!20!white] (tools) [right of=humanities] {\parbox{3cm}{Computing \\ Tools and \\ Methodologies}};
    \draw[very thick,red] (tools) edge [out=270,in=270,->] (humanities);
  \end{tikzpicture}
#+end_src

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.2.3-327-g3375f0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: best ways to generate simple diagrams?
  2019-05-07 17:52     ` Fraga, Eric
@ 2019-05-07 20:36       ` Matt Price
  2019-05-07 20:51         ` Martin Schöön
  0 siblings, 1 reply; 10+ messages in thread
From: Matt Price @ 2019-05-07 20:36 UTC (permalink / raw)
  To: Fraga, Eric, Org Mode


[-- Attachment #1.1: Type: text/plain, Size: 1074 bytes --]

hmm, I still get just the attached image (approx).  Presumably osmehting
wrong w/ my latex setup (I use latex only very rarely).

On Tue, May 7, 2019 at 1:52 PM Fraga, Eric <e.fraga@ucl.ac.uk> wrote:

> On Tuesday,  7 May 2019 at 13:22, Matt Price wrote:
> > I thought that a latex src block with :exports results would work, but
> > rather than a rendered graph I end up with a .png of the latex
> > instructions themselves. Here's what I am trying:
>
> It should work.  Try with the following header settings:
>
> #+header: :exports results
> #+header: :results file raw
> #+header: :file image.png
> #+header: :fit yes
> #+begin_src latex
>   \begin{tikzpicture}[node distance=4cm,minimum size=2cm]
>     \node[draw,fill=blue!20!white] (humanities) {Humanities};
>     \node[draw,fill=blue!20!white] (tools) [right of=humanities]
> {\parbox{3cm}{Computing \\ Tools and \\ Methodologies}};
>     \draw[very thick,red] (tools) edge [out=270,in=270,->] (humanities);
>   \end{tikzpicture}
> #+end_src
>
> --
> Eric S Fraga via Emacs 27.0.50, Org release_9.2.3-327-g3375f0
>

[-- Attachment #1.2: Type: text/html, Size: 1448 bytes --]

[-- Attachment #2: latex-headers.png --]
[-- Type: image/png, Size: 22904 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: best ways to generate simple diagrams?
  2019-05-07 20:36       ` Matt Price
@ 2019-05-07 20:51         ` Martin Schöön
  2019-05-08  5:47           ` Fraga, Eric
  0 siblings, 1 reply; 10+ messages in thread
From: Martin Schöön @ 2019-05-07 20:51 UTC (permalink / raw)
  To: Matt Price; +Cc: Org Mode, Fraga, Eric

[-- Attachment #1: Type: text/plain, Size: 84 bytes --]

Maybe missing a "\usepackage{tikz}"?
(That caught me out)

-- 
Martin Schöön

[-- Attachment #2: Type: text/html, Size: 222 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: best ways to generate simple diagrams?
  2019-05-06 18:17 best ways to generate simple diagrams? Matt Price
                   ` (2 preceding siblings ...)
  2019-05-07 11:25 ` Fraga, Eric
@ 2019-05-08  4:06 ` Marcin Borkowski
  3 siblings, 0 replies; 10+ messages in thread
From: Marcin Borkowski @ 2019-05-08  4:06 UTC (permalink / raw)
  To: Matt Price; +Cc: Org Mode


On 2019-05-06, at 20:17, Matt Price <moptop99@gmail.com> wrote:

> So, I'm finding more and more that I want to include simple diagrams in my
> course materials. At present I am generating them as svg's using Inkscape,
> but that feels really tiresome to me. I would much rather make them
> programmatically, preferably including the source code as an org-mode block.
>
> I thought ditaa would be the tool for this, but I cannot figure out how to
> do this work efficiently in ditaa.  So for instance, I have this simple svg
> file (attached). It consists of two text-containing  symmetrical rectangles
> separated by a bit of whitespace and connected by two curved arrows (one
> pointing from each of the rectangles to the other).
>
> Trying to replicate this in ditaa did not prove easy.  Editing feels
> extremely labourious.  Am I missing something?  Is there a really good
> tutorial somehwere that I'm just not finding? Or is there maybe another
> tool I should be using instead?

Eric beat me to mentioning TikZ, which I've been using to create all
sorts of drawings for the past ten years or so.

Another TeX-related tool is METAPOST.  TikZ is apparently inspired by it
a lot, and it has some very nice features (like solving systems of
linear equations given in a declarative style to get intersection points
of straight lines - very handy).  There is another macro system built on
top of it, called METAFUN (https://wiki.contextgarden.net/MetaFun).

Since you mentioned exporting to HTML, d3.js came to my mind
immediately.  I don't have a lot of experience with it, and its main aim
is something different, but it's definitely worth knowing about.

Last but not least, I guess writing directly in SVG format might or
might not be what you want.  (I remember ye olden days when they said
that XML was something to be written and read by humans...  And in some
cases this is in fact true!)

Hth,

--
Marcin Borkowski
http://mbork.pl

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: best ways to generate simple diagrams?
  2019-05-07 20:51         ` Martin Schöön
@ 2019-05-08  5:47           ` Fraga, Eric
  0 siblings, 0 replies; 10+ messages in thread
From: Fraga, Eric @ 2019-05-08  5:47 UTC (permalink / raw)
  To: Martin Schöön; +Cc: Org Mode

On Tuesday,  7 May 2019 at 22:51, Martin Schöön wrote:
> Maybe missing a "\usepackage{tikz}"?
> (That caught me out)

Ah, that is a very likely reason!  I have the following in my emacs
initialization for org:

  (add-to-list 'org-latex-packages-alist '("" "tikz"))
  (add-to-list 'org-latex-packages-alist '("" "xcolor"))

as I use tikz all the time... (so I'd forgotten it's not a default).

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.2.3-327-g3375f0

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-05-08  5:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-06 18:17 best ways to generate simple diagrams? Matt Price
2019-05-06 19:12 ` ckelty ckelty
2019-05-06 20:08 ` Heinz Tuechler
2019-05-07 11:25 ` Fraga, Eric
2019-05-07 17:22   ` Matt Price
2019-05-07 17:52     ` Fraga, Eric
2019-05-07 20:36       ` Matt Price
2019-05-07 20:51         ` Martin Schöön
2019-05-08  5:47           ` Fraga, Eric
2019-05-08  4:06 ` Marcin Borkowski

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).