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:
bottom
: direction of the arrow (either 'toright' or 'toleft'). No arrow ifNone
top
: direction of the arrow (either 'toright' or 'toleft'). No arrow ifNone
(default)left
: direction of the arrow (either 'totop' or 'tobottom'). No arrow ifNone
right
: direction of the arrow (either 'totop' or 'tobottom'). No arrow ifNone
(default)ax
: The matplotlib axes to draw the arrow on. If None, uses the current axesarrow_style
: any additional arguments passed toax_arrow()
Returns:
Axes
: the matplotlib axes
Usage
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