X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False,
# The half-arrows contain the midpoint of the stem,
# which we can omit from the full arrow. Including it
# twice caused a problem with xpdf.
coords = np.concatenate([left_half_arrow[:-2],
coords = np.concatenate([left_half_arrow[:-1],
right_half_arrow[-2::-1]])
else:
raise ValueError("Got unknown shape: %s" % shape)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 29 additions & 1 deletion lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import six
from six.moves import xrange
from itertools import chain
from itertools import chain, product
from distutils.version import LooseVersion
import io

Expand Down Expand Up @@ -263,6 +263,34 @@ def test_basic_annotate():
xytext=(3, 3), textcoords='offset points')


@image_comparison(baseline_images=['arrow_simple'],
extensions=['png'], remove_text=True)
def test_arrow_simple():
# Simple image test for ax.arrow
# kwargs that take discrete values
length_includes_head = (True, False)
shape = ('full', 'left', 'right')
head_starts_at_zero = (True, False)
# Create outer product of values
kwargs = list(product(length_includes_head, shape, head_starts_at_zero))

fig, axs = plt.subplots(3, 4)
for i, (ax, kwarg) in enumerate(zip(axs.flatten(), kwargs)):
ax.set_xlim(-2, 2)
ax.set_ylim(-2, 2)
# Unpack kwargs
(length_includes_head, shape, head_starts_at_zero) = kwarg
theta = 2 * np.pi * i / 12
# Draw arrow
ax.arrow(0, 0, np.sin(theta), np.cos(theta),
width=theta/100,
length_includes_head=length_includes_head,
shape=shape,
head_starts_at_zero=head_starts_at_zero,
head_width=theta / 10,
head_length=theta / 10)


def test_annotate_default_arrow():
# Check that we can make an annotation arrow with only default properties.
fig, ax = plt.subplots()
Expand Down
X Tutup