# Drawing arrows on axes

**URL:** <https://discourse.julialang.org/t/drawing-arrows-on-axes/30341>\
**Category:** Visualization\
**Tags:** plots\
**Created:** [October 26, 2019, 5:12pm UTC](https://discourse.julialang.org/t/drawing-arrows-on-axes/30341 "2019-10-26T17:12:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![squirrel](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@squirrel](https://discourse.julialang.org/u/squirrel)\
**Post date:** [October 26, 2019, 5:12pm UTC](https://discourse.julialang.org/t/drawing-arrows-on-axes/30341/1 "2019-10-26T17:12:33Z")

</div>

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

```julia
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.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [October 27, 2019, 2:40pm UTC](https://discourse.julialang.org/t/drawing-arrows-on-axes/30341/2 "2019-10-27T14:40:56Z")

</div>

Plots doesn’t offer axis line arrows

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [October 27, 2019, 4:06pm UTC](https://discourse.julialang.org/t/drawing-arrows-on-axes/30341/3 "2019-10-27T16:06:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 27, 2019, 4:29pm UTC](https://discourse.julialang.org/t/drawing-arrows-on-axes/30341/4 "2019-10-27T16:29:07Z")

</div>

Consider PGFPlotsX:

```julia
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)))

```

 ![plot](https://global.discourse-cdn.com/julialang/original/3X/b/4/b4f11d29d9341810835bfb55ea0efa626d12b891.png)

---

<div class="post-metadata">

**Author:** ![mbaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbaz/32/17295_2.png) [@mbaz](https://discourse.julialang.org/u/mbaz)\
**Post date:** [October 27, 2019, 9:17pm UTC](https://discourse.julialang.org/t/drawing-arrows-on-axes/30341/5 "2019-10-27T21:17:18Z")

</div>

It is possible if you use [Gaston.jl](https://github.com/mbaz/Gaston.jl) or [gnuplot.jl](https://github.com/gcalderone/Gnuplot.jl):

[http://www.gnuplotting.org/adding-arrows-to-the-axes/](http://www.gnuplotting.org/adding-arrows-to-the-axes/)

---

<div class="post-metadata">

**Author:** ![squirrel](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@squirrel](https://discourse.julialang.org/u/squirrel)\
**Post date:** [October 30, 2019, 7:21pm UTC](https://discourse.julialang.org/t/drawing-arrows-on-axes/30341/6 "2019-10-30T19:21:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![squirrel](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@squirrel](https://discourse.julialang.org/u/squirrel)\
**Post date:** [October 30, 2019, 7:28pm UTC](https://discourse.julialang.org/t/drawing-arrows-on-axes/30341/7 "2019-10-30T19:28:35Z")

</div>

[docs.juliaplots.org](http://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. 🙃

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 31, 2019, 6:20am UTC](https://discourse.julialang.org/t/drawing-arrows-on-axes/30341/8 "2019-10-31T06:20:02Z")

</div>

Yes, it has detailed documentation.

[https://kristofferc.github.io/PGFPlotsX.jl/stable/](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.

---

<div class="post-metadata">

**Author:** ![Elyco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elyco/32/18418_2.png) [@Elyco](https://discourse.julialang.org/u/Elyco)\
**Post date:** [October 27, 2022, 11:10am UTC](https://discourse.julialang.org/t/drawing-arrows-on-axes/30341/9 "2022-10-27T11:10:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [October 27, 2022, 12:35pm UTC](https://discourse.julialang.org/t/drawing-arrows-on-axes/30341/10 "2022-10-27T12:35:26Z")

</div>

A simple workaround in Plots.jl for this is:

```julia
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))

```

 ![Plots_arrows_on_axes](https://global.discourse-cdn.com/julialang/original/3X/2/0/206e4913d9758579dc6c74708eeaabea82e2d1a2.png)
