Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 330703c

Browse files
robmarkcoletacaswell
authored andcommitted
Add tests for patch_in_autoscale
1 parent 638f551 commit 330703c

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

lib/matplotlib/tests/test_artist.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,8 @@ def draw(self, renderer, extra):
564564
assert 'aardvark' == art.draw(renderer, extra='aardvark')
565565

566566

567-
def test_in_autoscale_true():
568-
# test autoscale is performed when in_autoscale=True.
567+
def test_line_in_autoscale_true():
568+
# test autoscale is performed when in_autoscale=True for a line.
569569
fig, ax = plt.subplots()
570570
ax.plot([0, 1])
571571
ax.plot([0, 1, 2, 3], in_autoscale=True)
@@ -574,11 +574,32 @@ def test_in_autoscale_true():
574574
assert ax.get_xlim() == ax.get_ylim() == (0, 3)
575575

576576

577-
def test_in_autoscale_false():
578-
# test autoscale is not performed when in_autoscale=False.
577+
def test_line_in_autoscale_false():
578+
# test autoscale is not performed when in_autoscale=False for a line.
579579
fig, ax = plt.subplots()
580580
ax.plot([0, 1])
581581
ax.plot([0, 1, 2, 3], in_autoscale=False)
582582
ax.margins(0)
583583
ax.autoscale_view()
584584
assert ax.get_xlim() == ax.get_ylim() == (0, 1) # The default limits.
585+
586+
def test_patch_in_autoscale_true():
587+
# test autoscale is performed when in_autoscale=True for a patch.
588+
fig, ax = plt.subplots()
589+
ax.plot([0, 1])
590+
ax.bar([0, 1, 2, 3], [0, 10, 20, 30], width=0.5, in_autoscale=True)
591+
ax.margins(0)
592+
ax.autoscale_view()
593+
assert ax.get_xlim() == (-.25, 3.25)
594+
assert ax.get_ylim() == (0, 30)
595+
596+
597+
def test_patch_in_autoscale_false():
598+
# test autoscale is not performed when in_autoscale=False for a patch.
599+
fig, ax = plt.subplots()
600+
ax.plot([0, 1])
601+
ax.bar([0, 1, 2, 3], [0, 10, 20, 30], width=0.5, in_autoscale=False)
602+
ax.margins(0)
603+
ax.autoscale_view()
604+
assert ax.get_xlim() == (0, 1)
605+
assert ax.get_ylim() == (0, 1)

0 commit comments

Comments
 (0)