# Asymptote as a Julia package?

#1

Based on the follwing data type for trees

type Tree{T}
key:: T
st :: Array{Tree{T},1}
end


I have written a small program with plots such trees using Asymptote (based on ANDREW J. KENNEDYs algorithm for drawing trees, J. Functional Programming 6 (3): 527–534, May 1996). The program generates a sequence of draw commands, stores them as asy-file and does an external call of Asymptote for this file.
Output can be either eps, png, pdf or svg. (Tikz is still planned. In this case Asymptote isn’t used)

As an example this is the output of a randomly generated tree:

When writing this program I thought having (a reimplementation of) Asymptote as Julia package would be great (provided permission of the developers of Asymptote is given). What are your opinions?

#2

We do have a Cairo.jl package, and there is the Compose.jl package if you want a simpler higher-level graphics interface, and GLVisualize.jl … not sure what re-implementing Asymptote would add? Certainly you would have to re-think the Asymptote syntax (which is C++ like) for Julia’s idioms.

#3

LaTeX typesetting of labels (or is this already in Cairo / Compose? Either way it would probably be easier to add this to existing packages.)

#4

There is

but perhaps rewriting it to render to an intermediate format which is useful for other purposes would be a good project for a library.

#5

How does Asymptote compare to Tikz? The latter is already supported in TikzPictures.jl and uses latex to generate the figures.

Tools to generate inline, potentially interactive graphics in notebooks are a good thing to have for sure.

#6

You’re volunteering? I was active for some time to find a latex-style labeling solution, but did not make real progress. It really look’s like this is missing as independent library. Mathjax looked like a solution, but then i learned, they are not outputting svg, but a special html style where you need a browser rendering entity. The Mozilla MathML project looked also promising, but access to the logic goes via Gecko and that brings in the (whole) C++ API library chaos.
GtkMathView also is mentioned several times, but seems abandoned.

#7

#8

There is also TikzGraphs.jl which does graphs in LaTeX. It is possible that there is already a graph layout that does what you want.

#9

Thanks for all the replies.

There is also TikzGraphs.jl” Unfortunately I wasn’t aware of this package (my fault! ). I like Tikz and I think this package indeed is very useful.
Personally I believe that concerning 3D Asymptote has some advantages over Tikz. However when reading that Asymptote has more than 80.000 lines of low level C++ code (as of June 2010) I have given up the idea of a reimplementation as a Julia package.

#10

80,000 lines of C++ ≈ 8,000 lines of Julia

#11

Coming from C++, I’d say that’s about right. But what really counts is the number of hairs left on your head when you’re finished, I think there it’s the other way around

#12

As a corollary: years to develop in C++ is one productive weekend in Julia.

#13

This function doesn’t do much more than change font sizes and styles:

julia> Cairo.tex2pango("\$-b \\pm \\sqrt{b^2 - 4ac} \\over 2a \$", 12)
"\$−b ±\\sqrtb<sup><span font=\"7.416407813432845\">2</span></sup> − 4ac \\over2a \$"


(Obvious really that it wouldn’t do LaTeX, when you think about it. :))

#14

Oh, i just learned from Chris’ message, that TeX can be redone in Julia in one productive weekend…

#15

for inline interactive figures I think D3 is much better & more modern.

#16

This one I suppose?

Is it available for use from within Julia? Looking at the examples, the interface seems very low-level compared to Tikz, but I must say the results are stunning.

#17

yes.
there is a simple julia wrapper : https://github.com/jverzani/DThree.jl but you will still need to write D3 itself.

D3 is basically 2D vector graphics (svg) programming, analog to directly programming openGL for 3D. So it’s good if you want to develop your own custom visualisations. For a stunning example of this: http://www.r2d3.us/visual-intro-to-machine-learning-part-1/

Now if your looking for a more high level plotting lib: use plotlyJS.jl. The 2D plots of plotly are itself based on D3.js (the 3D ones are based on webGL).

#18

How does D3 do TeX labels?

#19

#20

MathJax again -> browser rendering.