Drawing arrows on axes

I’m trying to add arrows to my axes, but it isn’t working. I have

using Plots 

x(u) = u
y(u) = sqrt(u)
y2(u) = -sqrt(u)
plot(x, [y, y2], 0, 5,
    framestyle = :origin,
    legend = :none,
    linecolor = :blue,
    draw_arrow = true,
    axis = (draw_arrow = true)
)

Neither of the last two attributes throws an error, but neither add the arrows I want.

Plots doesn’t offer axis line arrows

1 Like

is there a triangle shape function? :slight_smile: I bet we could fix that or atleast provide a hot-fix

Consider PGFPlotsX:

using PGFPlotsX
x = range(0, 5; length = 200)
y = .√x
@pgf Axis({ axis_lines = "left" },
          Plot({ no_marks, blue }, Table(x, y)),
          Plot({ no_marks, blue }, Table(x, .-y)))

3 Likes

It is possible if you use Gaston.jl or gnuplot.jl:

http://www.gnuplotting.org/adding-arrows-to-the-axes/

This is very pretty. Do you know where I can find more information on using PGFPlotsX in julia? Does it have documentation? I could only find examples for making PGFPlots in Latex.

docs.juliaplots.org listed it as an attribute, but you’re right. When I look at supported attributes, it isn’t supported by any of the libraries. :upside_down_face:

1 Like

Yes, it has detailed documentation.

https://kristofferc.github.io/PGFPlotsX.jl/stable/

But of course the pgfplots (ie the LaTeX package) docs are also very useful, as explained in the docs — PGFPlotsX is just a thin layer.

If you can’t find something, just ask on this forum — quite a few examples came from actual use cases.

1 Like

The topic is old but there is still no difference between plot(draw_arrow=true) and plot(draw_arrow=false) although it appears in the axis’ attributes page.

A simple workaround in Plots.jl for this is:

using Plots; gr()

p = plot(exp ∘ exp, yaxis=:log, legend=:topleft, label="exp(exp(x))")
xl, yl = xlims(p), ylims(p)
annotate!(xl[2],yl[1], text('\u27A4',7,:black,rotation=0))
annotate!(xl[1],yl[2], text('\u27A4',7,:black,rotation=90))

4 Likes