# PGFPlotsX arrows and axes questions

**URL:** <https://discourse.julialang.org/t/pgfplotsx-arrows-and-axes-questions/30658>\
**Category:** Visualization\
**Created:** [November 3, 2019, 4:24pm UTC](https://discourse.julialang.org/t/pgfplotsx-arrows-and-axes-questions/30658 "2019-11-03T16:24:22Z")\
**Posts on this page:** 2\
**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:** [November 3, 2019, 4:24pm UTC](https://discourse.julialang.org/t/pgfplotsx-arrows-and-axes-questions/30658/1 "2019-11-03T16:24:23Z")

</div>

```julia
using PGFPlotsX

x = range(0, 5; length = 200)
y = .√x

plottheme = @pgf {no_marks, blue}

@pgf TikzPicture(
    Axis({
            xmin = -4, xmax = 4, xtick = -5:1:5,
            ymin = -4, ymax = 4, ytick = -5:1:5,
            width = 500,
            axis_lines = "middle",
            axis_line_style = ["<->","very thick"],
            grid = "both",
            title="My Figure"
        },
        Plot(plottheme, Table(x, y)),
        Plot(plottheme, Table(x, .-y))
    )
)

```

How do I add arrows at the ends of the function?

How can I make the arrows at the ends of the axes look like triangle? [This suggests](https://tex.stackexchange.com/questions/27279/how-to-make-an-arrow-bigger-and-change-its-color-in-tikz/27287#27287) it’s possible.

How do I to make the axes extend beyond the grid? For example, this suggests I can [“shorten” the axes somehow](https://tex.stackexchange.com/a/135900).

---

<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:** [November 3, 2019, 6:00pm UTC](https://discourse.julialang.org/t/pgfplotsx-arrows-and-axes-questions/30658/2 "2019-11-03T18:00:13Z")

</div>

PGFPlotsX is a really thin layer over pgfplots, so the best way to approach these problems is to figure out how one would do it in LaTeX, then just apply it. Maybe making an MWE in LaTeX/pgfplots could help you on StackOverflow.

> [@squirrel](#):
>
> How do I add arrows at the ends of the function?

This I don’t know how to do; maybe add a quiver plot that overlaps?

> [@squirrel](#):
>
> How can I make the arrows at the ends of the axes look like triangle?

The pgfplots manual has examples of customizing the arrow styles. The tikz/pgf manual has a detailed guide on them.

> [@squirrel](#):
>
> How do I to make the axes extend beyond the grid?

I think the example you link actually does that (it shortens by a negative number), but I am not sure how to combine it with the arrow tip.

FWIW, this gives you triangular arrows:

```julia
using PGFPlotsX

x = range(0, 5; length = 200)
y = .√x

plottheme = @pgf {no_marks, blue}

push!(PGFPlotsX.CUSTOM_PREAMBLE, raw"\usetikzlibrary{arrows.meta}")

@pgf Axis({ xmin = -4, xmax = 4, xtick = -5:1:5,
            ymin = -4, ymax = 4, ytick = -5:1:5,
            width = 500,
            axis_lines = "middle",
            axis_line_style = ["<->","very thick"],
            grid = "both",
            title="My Figure",
            "x axis line style" = {"-Triangle"},
            "y axis line style" = {"-Triangle"},
            },
          Plot(plottheme, Table(x, y)),
          Plot(plottheme, Table(x, .-y)))

```

 ![x](https://global.discourse-cdn.com/julialang/original/3X/2/1/21e7eb5d699fc253bcb60cc908d4dd9e8e39708a.png)

Also, if you need this to illustrate, not plot data, consider just using TikZ directly, it has a lot of flexibility.
