| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + Equal aspect axes for 3D plots disabled | ||
| 2 | + ``````````````````````````````````````` | ||
| 3 | + | ||
| 4 | + Setting the aspect on 3D axes previously returned non-sensical | ||
| 5 | + results (e.g. see https://github.com/matplotlib/matplotlib/issues/1077). | ||
| 6 | + Calling ``ax.set_aspect('equal')`` or ``ax.set_aspect(num)`` | ||
| 7 | + on a 3D axes now raises a ``NotImplementedError``. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1271,11 +1271,18 @@ def set_aspect(self, aspect, adjustable=None, anchor=None, share=False): | |||
| 1271 | 1271 | if not (cbook._str_equal(aspect, 'equal') | |
| 1272 | 1272 | or cbook._str_equal(aspect, 'auto')): | |
| 1273 | 1273 | aspect = float(aspect) # raise ValueError if necessary | |
| 1274 | + | ||
| 1275 | + if (not cbook._str_equal(aspect, 'auto')) and self.name == '3d': | ||
| 1276 | + raise NotImplementedError( | ||
| 1277 | + 'It is not currently possible to manually set the aspect ' | ||
| 1278 | + 'on 3D axes') | ||
| 1279 | + | ||
| 1274 | 1280 | if share: | |
| 1275 | 1281 | axes = set(self._shared_x_axes.get_siblings(self) | |
| 1276 | 1282 | + self._shared_y_axes.get_siblings(self)) | |
| 1277 | 1283 | else: | |
| 1278 | 1284 | axes = [self] | |
| 1285 | + | ||
| 1279 | 1286 | for ax in axes: | |
| 1280 | 1287 | ax._aspect = aspect | |
| 1281 | 1288 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,13 @@ | |||
| 11 | 11 | import numpy as np | |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | + def test_aspect_equal_error(): | ||
| 15 | + fig = plt.figure() | ||
| 16 | + ax = fig.add_subplot(111, projection='3d') | ||
| 17 | + with pytest.raises(NotImplementedError): | ||
| 18 | + ax.set_aspect('equal') | ||
| 19 | + | ||
| 20 | + | ||
| 14 | 21 | @image_comparison(baseline_images=['bar3d'], remove_text=True) | |
| 15 | 22 | def test_bar3d(): | |
| 16 | 23 | fig = plt.figure() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments