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

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:

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