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

Skip to content

fix argument checks in axis/base.margins #3078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 28, 2014
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/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ def margins(self, *args, **kw):
mx = my = args[0]
elif len(args) == 2:
mx, my = args
else:
elif len(args) > 2:
raise ValueError("more than two arguments were supplied")
if mx is not None:
self.set_xmargin(mx)
Expand Down
19 changes: 19 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3109,6 +3109,25 @@ def test_pie_ccw_true():
# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')

@cleanup
def test_margins():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a @cleanup to make sure we don't like figures in the tests.

# test all ways margins can be called
data = [1, 10]

fig1, ax1 = plt.subplots(1, 1)
ax1.plot(data)
ax1.margins(1)
assert_equal(ax1.margins(), (1, 1))

fig2, ax2 = plt.subplots(1, 1)
ax2.plot(data)
ax2.margins(1, 0.5)
assert_equal(ax2.margins(), (1, 0.5))

fig3, ax3 = plt.subplots(1, 1)
ax3.plot(data)
ax3.margins(x=1, y=0.5)
assert_equal(ax3.margins(), (1, 0.5))

@cleanup
def test_pathological_hexbin():
Expand Down