Skip to content

arrow_spines

drawarrow.arrow_spines.arrow_spines(bottom='toright', left='totop', right=None, top=None, ax=None, **arrow_style)

Replace matplotlib spines with arrows instead. By default it adds an arrow at the bottom spine (to the right) and an arrow at the left spine (to the top), but it can customized. See examples below.

Parameters:

Name Type Description Default
bottom str | None

direction of the arrow (either 'toright' or 'toleft'). No arrow if None

'toright'
top str | None

direction of the arrow (either 'toright' or 'toleft'). No arrow if None (default)

None
left str | None

direction of the arrow (either 'totop' or 'tobottom'). No arrow if None

'totop'
right str | None

direction of the arrow (either 'totop' or 'tobottom'). No arrow if None (default)

None
ax Axes | None

The matplotlib axes to draw the arrow on. If None, uses the current axes

None
arrow_style

any additional arguments passed to ax_arrow()

{}

Returns:

Type Description
Axes

Axes: the matplotlib axes


Examples

# mkdocs: render
import matplotlib.pyplot as plt
from drawarrow import arrow_spines

fig, ax = plt.subplots()

ax.scatter([1, 2, 3, 8, 6, 10], [2, 5, 3, 9, 2, 10])

arrow_spines(ax=ax, color="red")
# mkdocs: render
import matplotlib.pyplot as plt
from drawarrow import arrow_spines

fig, ax = plt.subplots()

ax.scatter([1, 2, 3, 8, 6, 10], [2, 5, 3, 9, 2, 10])

arrow_spines(
   right="totop",
   bottom="toleft",
   left=None, # remove left spine
   ax=ax,
   color="red",
)
# mkdocs: render
import matplotlib.pyplot as plt
from drawarrow import arrow_spines

fig, ax = plt.subplots()

ax.scatter([1, 2, 3, 8, 6, 10], [2, 5, 3, 9, 2, 10])

arrow_spines(
   ax=ax,
   color="#7b2e8e", # purple
   width=3,
   head_length=15,
   head_width=10,
)

ax.tick_params(size=0, pad=15) # remove ticks and add padding


Going further