# PGFPlotsX arrows and axes questions

``````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 it’s possible.

How do I to make the axes extend beyond the grid? For example, this suggests I can “shorten” the axes somehow.

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.

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

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

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:

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

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