Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Added axes inversion to cla() #8455

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 14 commits into from
Apr 16, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
changed to use set_xlim instead, also added tests
  • Loading branch information
jrmlhermitte authored and Julien L committed Apr 14, 2017
commit 76bdae4bfebdc0a5fbcdc0c57c823bc89cb0a243
6 changes: 4 additions & 2 deletions 6 lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,8 @@ def cla(self):
self.xaxis.set_minor_locator(minl)
else:
self.xaxis._set_scale('linear')
self.viewLim.intervalx = (0, 1)
#self.viewLim.intervalx = (0, 1)
self.set_xlim(0,1)

if self._sharey is not None:
self.yaxis.major = self._sharey.yaxis.major
Expand All @@ -1021,7 +1022,8 @@ def cla(self):
self.yaxis.set_minor_locator(minl)
else:
self.yaxis._set_scale('linear')
self.viewLim.intervaly = (0, 1)
#self.viewLim.intervaly = (0, 1)
self.set_ylim(0,1)

# update the minor locator for x and y axis based on rcParams
if (rcParams['xtick.minor.visible']):
Expand Down
42 changes: 42 additions & 0 deletions 42 lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,48 @@ def test_twin_inherit_autoscale_setting():
assert ax_y_on.get_autoscaley_on()
assert not ax_y_off.get_autoscaley_on()

@cleanup
def test_inverted_cla():
# Github PR #5450. Setting autoscale should reset
# axes to be non-inverted.
# plotting an image, then 1d graph, axis is now down
fig = plt.figure(0);
ax = fig.gca()
# test that a new axis is not inverted per default
assert not(ax.xaxis_inverted())
assert not(ax.yaxis_inverted())
img = np.random.random((100,100))
ax.imshow(img)
# test that a image axis is inverted
assert not(ax.xaxis_inverted())
assert ax.yaxis_inverted()
ax.cla()
x = np.linspace(0,2*np.pi,100);
ax.plot(x,np.cos(x))
assert not(ax.xaxis_inverted())
assert not(ax.yaxis_inverted())

# autoscaling should not bring back axes to normal
ax.cla()
ax.imshow(img)
plt.autoscale()
assert not(ax.xaxis_inverted())
assert ax.yaxis_inverted()

# two shared axes. Clearing the master axis should bring axes in shared
# axies back to normal
ax0 = plt.subplot(211)
ax1 = plt.subplot(212, sharey=ax0)
ax0.imshow(img)
ax1.plot(x,np.cos(x))
ax0.cla()
assert not(ax1.yaxis_inverted())
ax1.cla()
# clearing the nonmaster should not touch limits
ax0.imshow(img)
ax1.plot(x,np.cos(x))
ax1.cla()
assert ax.yaxis_inverted()

@image_comparison(baseline_images=["minorticks_on_rcParams_both"],
extensions=['png'])
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.