Search code examples
juliaannotatearrows

Use GR Arrow Styles in Julia.Plots


I'd like to annotate a point in a plot I draw using julia Plots with the GR backend. I get the arrows drawn with

plot([(pos1), (pos2)], line=:arrow)

As expected, this draws a :simple arrow. However, I can not figure out how to get :filled or :closed arrows. I have tried several permutations:

plt1 = plot([(pos1), (pos2)], line=:arrow, arrow=arrow(:closed))
plt2 = plot([(pos1), (pos2)], line=:arrow, arrow=:closed)

And also directly calling the GR function

plt3 = plot([(pos1), (pos2)], line=:arrow, arrow_style=arrow(:closed))
plt4 = plot([(pos1), (pos2)], line=:arrow, arrow=arrow_style(:closed))

Is there a way to switch arrow styles on Julia.Plots?


Solution

  • You just have to get rid of the line = :arrow keyword argument. line in Plots is a magic argument and line = :arrow will be converted to arrow = :arrow internally during the preprocessing pipeline, overwriting the provided arrow attribute.

    plot(rand(2), rand(2), arrow = :closed, lims = (0, 1))
    

    gives

    enter image description here