Here is a quick-and-dirty primer based on my own experience:

1. Let's draw some circles:

compose(context(), circle(0.5, 0.5, 0.3))

Each compose() call takes a context() and zero or more objects which can be
concrete things to draw like circle() or abstract things like fill colors.
The idea is that compose() composites everything in the current context().

compose(context(), circle(0.5, 0.5, 0.3), stroke("blue"), linewidth(5mm),
fill("red"))

The context also lets you do things like change the coordinate system for
the current context().

compose(context(units=UnitBox(-1,-1,4,4)), circle(0.5, 0.5, 0.3))



2. Let's draw some (poly-)lines:

compose(context(), line([(0., 0.), (1., 1.), ]), stroke("black"))

compose(context(), line([(0., 0.), (1., 0.), (1., 1.), ]), stroke("blue"))



3. Here is a short snippet to visualize small matrices as Hinton plots

using Compose
Compose.set_default_graphic_size(4inch, 4inch)

function plothinton{T<:Real}(M::AbstractMatrix{T})
    Elements = Any[]
    m, n= size(M)
    for i=1:m, j=1:n
        z = abs(M[i,j])
        thecolor = M[i,j]<0 ? "white" : "black"
        push!(Elements, compose(context(units=UnitBox(0.5,0.5,m,n)),
            rectangle(i-z/2, j-z/2, z, z), stroke(thecolor),
fill(thecolor)))
    end
    compose(context(), rectangle(0,0,1,1), fill("lavender"), Elements...)
end

#Simple example
x=2rand(25, 25).-1 |> x-> (x+x')/2
plothinton(x)

#end

Notice in this example that there are two different sets of contexts with
different coordinates.

I also like making an array of Compose elements and then splatting it into
a final compose() command.

Thanks,

Jiahao Chen
Staff Research Scientist
MIT Computer Science and Artificial Intelligence Laboratory

On Mon, Nov 24, 2014 at 5:34 PM, Isaiah Norton <isaiah.nor...@gmail.com>
wrote:

> There are some nice Compose examples in the "parallel prefix" notebook,
> here: https://github.com/jiahao/ijulia-notebooks
>
>
> http://nbviewer.ipython.org/github/jiahao/ijulia-notebooks/blob/master/2014-08-06-parallel-prefix.ipynb
>
>
> On Sat, Nov 22, 2014 at 4:08 AM, <ccsv.1056...@gmail.com> wrote:
>
>> Are there any tutorials for Compose.jl other than the documentation page?
>>
>> I want to try to make pie charts and venn diagrams.
>>
>>
>

Reply via email to