Is it possible to display a "turtle" .svg in the juno plot pane

I’m going through the “Think Julia” book, I’m in chapter 4 creating turtle drawings. Is there a way to view my drawing in the Juno plot pane so I don’t have to go back and forth between Juno and my file manager to verify my output? I call my turtle functions through the svg macro:

@svg begin
myTurtleDrawing()
end

I would like to see it show up in the plot pane if possible similar to when you call plot().

Thanks.

What IDE are you using? Under Atom when I do the commands plots is updated with the image.

1 Like

I’m using Juno, here is my code, (i’ve tried it both in the REPL and running as a script):

using ThinkJulia

function polygon(t, n, len)
    angle = 360 / n 
    for i in 1:n    
        forward(t, len)
        turn(t, -angle)
    end
end

turtle = Turtle()
@svg begin
    polygon(turtle, 7, 70)
end

I figured out that I think its trying to show the svg, I had the plot plane closed and ran the script and the plot plane immediately appeared but just blank.

Not sure what is happening…if you haven’t yet you might try restarting Julia and trying it again. Also if plots has scroll bars scroll to the right and down see if the image is just hiding.

Other than that maybe try (in a new session):

Pkg.add("Luxor")
using Luxor
@svg begin sethue("red"); circle(-200, -200, 20, :fill) end

Luxor appears to be the package ThinkJulia is using to do the turtle. That code should use it to draw a red circle in plots.

interesting, I wonder if its Juno. Your code produces an svg just fine and the plot pane “shows it” (in that I can “forget” the plot by pressing the x button) but its just blank. The svg file shows up in my file tree and I can view the red circle with an image viewer. It probably has something do with the this method error I get in the linter after running your code: (but the process completes successfully?):

Error Julia : MethodError(convert, (Symbol, :($(Expr(:., :Luxor)))), 0x00000000000069ff)

thanks for the help on such a trivial thing!