Adding Compose circles/lines/polygons to Gadfly plots?

560 views
Skip to first unread message

Sheehan Olver

unread,
Dec 9, 2014, 4:05:02 PM12/9/14
to julia...@googlegroups.com

I want to add, say, a triangle or circle to a Gadfly plot.  The following works

compose(render(plot(x=1:10,y=1:10)),circle(0.5,0.5,0.1))

But I want the circle to use the same coordinate system as the plot.  Any advice?


Sheehan Olver

unread,
Jan 8, 2015, 11:28:03 PM1/8/15
to julia...@googlegroups.com
I came across this which answers my question:

Nils Gudat

unread,
Jan 9, 2015, 5:22:46 AM1/9/15
to julia...@googlegroups.com
That's a nice feature to know about, but it seems to suffer from the problem that it doesn't scale with the rest of the graph if one uses the zoom functionality (i.e. the circles don't stay in position relative to the graph if you change the display of the graph). 

Daniel Jones

unread,
Jan 9, 2015, 2:09:16 PM1/9/15
to julia...@googlegroups.com
Fixed in master now. Thanks for pointing that out.

Kaj Wiik

unread,
Jan 9, 2015, 7:42:38 PM1/9/15
to julia...@googlegroups.com
Julia 0.3.5
Gadfly 0.3.10

julia> plot(sin, 0, 2pi, Guide.annotation(compose(context(), circle([pi/2, 3*pi/2], [1.0, -1.0], [2mm]), fill(nothing), stroke("orange"))))
ERROR: annotation not defined

??

Kaj

Daniel Jones

unread,
Jan 10, 2015, 2:01:03 PM1/10/15
to julia...@googlegroups.com
Kaj,

Guide.annotation was recently added. I haven't tagged a new version since its inclusion, so you need to either checkout master (with Pkg.checkout("Gadfly")) or wait until I tag 0.3.11.

Kaj Wiik

unread,
Jan 10, 2015, 4:49:29 PM1/10/15
to julia...@googlegroups.com
Daniel,

Thanks, works now perfectly, I had to restart julia after checkout to get it working. In fact this was my suspicion but did not know how to get the master. 

This is indeed a very friendly community, many thanks!

Kaj
Reply all
Reply to author
Forward
0 new messages