forked from matplotlib/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_container.py
More file actions
78 lines (55 loc) · 1.91 KB
/
test_container.py
File metadata and controls
78 lines (55 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import numpy as np
from numpy.testing import assert_array_equal
import matplotlib.pyplot as plt
def test_stem_remove():
ax = plt.gca()
st = ax.stem([1, 2], [1, 2])
st.remove()
def test_errorbar_remove():
# Regression test for a bug that caused remove to fail when using
# fmt='none'
ax = plt.gca()
eb = ax.errorbar([1], [1])
eb.remove()
eb = ax.errorbar([1], [1], xerr=1)
eb.remove()
eb = ax.errorbar([1], [1], yerr=2)
eb.remove()
eb = ax.errorbar([1], [1], xerr=[2], yerr=2)
eb.remove()
eb = ax.errorbar([1], [1], fmt='none')
eb.remove()
def test_nonstring_label():
# Test for #26824
plt.bar(np.arange(10), np.random.rand(10), label=1)
plt.legend()
def test_barcontainer_position_centers__bottoms__tops():
fig, ax = plt.subplots()
pos = [1, 2, 4]
bottoms = np.array([1, 5, 3])
heights = np.array([2, 3, 4])
container = ax.bar(pos, heights, bottom=bottoms)
assert_array_equal(container.position_centers, pos)
assert_array_equal(container.bottoms, bottoms)
assert_array_equal(container.tops, bottoms + heights)
container = ax.barh(pos, heights, left=bottoms)
assert_array_equal(container.position_centers, pos)
assert_array_equal(container.bottoms, bottoms)
assert_array_equal(container.tops, bottoms + heights)
def test_piecontainer_remove():
fig, ax = plt.subplots()
pie = ax.pie([2, 3], labels=['foo', 'bar'], autopct="%1.0f%%")
ax.pie_label(pie, ['baz', 'qux'])
assert len(ax.patches) == 2
assert len(ax.texts) == 6
pie.remove()
assert not ax.patches
assert not ax.texts
def test_piecontainer_unpack_backcompat():
fig, ax = plt.subplots()
wedges, texts, autotexts = ax.pie(
[2, 3], labels=['foo', 'bar'], autopct="%1.0f%%", labeldistance=None)
assert len(wedges) == 2
assert isinstance(texts, list)
assert not texts
assert len(autotexts) == 2