fig_arrow
drawarrow.main.fig_arrow(tail_position, head_position, inflection_position=None, double_headed=False, fill_head=True, invert=False, radius=0, width=1, head_width=4, head_length=8, fig=None, shadow_style=None, **kwargs)
Draw an arrow on a Matplotlib figure using a FancyArrowPatch
. The coordinate
system used is that of a Matplotlib Figure (from 0 to 1).
This function is very similar to what ax_arrow()
does: only
the change of coordinate system and the fig/ax
arguments. You can find out
more about how coordinate systems work in Matplotlib
here.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tail_position
|
list[float] | tuple[float]
|
Position of the tail of the arrow |
required |
head_position
|
list[float] | tuple[float]
|
Position of the head of the arrow |
required |
inflection_position
|
list[float] | tuple[float] | None
|
Current behavior may be unexpected and will probably change in the future. Optional position of the inflection point |
None
|
double_headed
|
bool
|
Whether the arrow has two heads or not |
False
|
fill_head
|
bool
|
Whether the arrowhead is filled or not |
True
|
invert
|
bool
|
Whether to invert or not the angle of the arrow (only used if |
False
|
radius
|
float
|
Rounding radius of the edge. If |
0
|
width
|
float
|
Width of the tail of the arrow |
1
|
head_width
|
float
|
Head width of the tail of the arrow |
4
|
head_length
|
float
|
Head length of the tail of the arrow |
8
|
fig
|
Figure | None
|
matplotlib figure to draw the arrow on. If it is not supplied, it will use |
None
|
shadow_style
|
dict | None
|
dictionary with arguments passed to |
None
|
useful
|
arguments are
|
offset: the offset between the arrow and its shadow (x, y) shadow_color: the color of the shadow alpha: the opacity of the shadow |
required |
kwargs
|
any additional arguments passed to |
{}
|
Returns:
Type | Description |
---|---|
FancyArrowPatch
|
|
Examples
# mkdocs: render
import matplotlib.pyplot as plt
from drawarrow import fig_arrow
fig, ax = plt.subplots()
ax.scatter([1, 2, 3, 8, 6, 10], [2, 5, 3, 9, 2, 10])
fig_arrow(
head_position=[0.6, 0.7],
tail_position=[0.2, 0.2],
radius=0.3,
color="red",
fill_head=False, # don't fill head
fig=fig,
)
# mkdocs: render
import matplotlib.pyplot as plt
from drawarrow import fig_arrow
fig, ax = plt.subplots()
ax.scatter([1, 2, 3, 8, 6, 10], [2, 5, 3, 9, 2, 10])
fig_arrow(
head_position=[0.6, 0.7],
tail_position=[0.2, 0.2],
radius=0.3,
color="black",
double_headed=True, # arrow with 2 heads
fig=fig,
)
# mkdocs: render
import matplotlib.pyplot as plt
from drawarrow import fig_arrow
fig, ax = plt.subplots()
ax.scatter([1, 2, 3, 8, 6, 10], [2, 5, 3, 9, 2, 10])
fig_arrow(
head_position=[0.6, 0.7],
tail_position=[0.2, 0.2],
radius=0.9, # bended arrow
color="blue",
fig=fig,
)
# mkdocs: render
import matplotlib.pyplot as plt
from drawarrow import fig_arrow
fig, ax = plt.subplots()
ax.scatter([1, 2, 3, 8, 6, 10], [2, 5, 3, 9, 2, 10])
fig_arrow(
head_position=[0.6, 0.7],
tail_position=[0.2, 0.2],
head_length=20, # head length
head_width=10, # head width
color="#3a46a4",
fig=fig,
)
# mkdocs: render
import matplotlib.pyplot as plt
from drawarrow import fig_arrow
fig, ax = plt.subplots()
ax.scatter([1, 2, 3, 8, 6, 10], [2, 5, 3, 9, 2, 10])
fig_arrow(
head_position=[0.6, 0.7],
tail_position=[0.2, 0.2],
head_length=20, # head length
head_width=10, # head width
width=3,
radius=0.1,
shadow_style={"offset": (2.5, -4)},
color="#3aa484",
fig=fig,
)