| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
20 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -196,7 +196,7 @@ <h3>We're updating the default styles for Matplotlib 2.0</h3> | |||
| 196 | 196 | ||
| 197 | 197 | <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> | |
| 198 | 198 | <a href="{{ pathto('index') }}"><img src="{{ | |
| 199 | - pathto("_static/logo2.png", 1) }}" border="0" alt="matplotlib"/></a> | ||
| 199 | + pathto("_static/logo2.svg", 1) }}" width="540px" border="0" alt="matplotlib"/></a> | ||
| 200 | 200 | </div> | |
| 201 | 201 | ||
| 202 | 202 | {% endblock %} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,3 +13,15 @@ | |||
| 13 | 13 | axes_divider_api.rst | |
| 14 | 14 | axes_grid_api.rst | |
| 15 | 15 | axis_artist_api.rst | |
| 16 | + | ||
| 17 | + | ||
| 18 | + ####################################### | ||
| 19 | + The Matplotlib axes_grid1 Toolkit API | ||
| 20 | + ####################################### | ||
| 21 | + | ||
| 22 | + :Release: |version| | ||
| 23 | + :Date: |today| | ||
| 24 | + | ||
| 25 | + .. toctree:: | ||
| 26 | + | ||
| 27 | + inset_locator_api.rst | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + :mod:`mpl_toolkits.axes_grid1.inset_locator` | ||
| 2 | + ============================================ | ||
| 3 | + | ||
| 4 | + .. automodule:: mpl_toolkits.axes_grid1.inset_locator | ||
| 5 | + :members: | ||
| 6 | + :undoc-members: | ||
| 7 | + :show-inheritance: | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1656,7 +1656,7 @@ class Grouper(object): | |||
| 1656 | 1656 | False | |
| 1657 | 1657 | ||
| 1658 | 1658 | """ | |
| 1659 | - def __init__(self, init=[]): | ||
| 1659 | + def __init__(self, init=()): | ||
| 1660 | 1660 | mapping = self._mapping = {} | |
| 1661 | 1661 | for x in init: | |
| 1662 | 1662 | mapping[ref(x)] = [ref(x)] | |
@@ -1708,6 +1708,14 @@ def joined(self, a, b): | |||
| 1708 | 1708 | except KeyError: | |
| 1709 | 1709 | return False | |
| 1710 | 1710 | ||
| 1711 | + def remove(self, a): | ||
| 1712 | + self.clean() | ||
| 1713 | + | ||
| 1714 | + mapping = self._mapping | ||
| 1715 | + seta = mapping.pop(ref(a), None) | ||
| 1716 | + if seta is not None: | ||
| 1717 | + seta.remove(ref(a)) | ||
| 1718 | + | ||
| 1711 | 1719 | def __iter__(self): | |
| 1712 | 1720 | """ | |
| 1713 | 1721 | Iterate over each of the disjoint sets as a list. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -916,7 +916,7 @@ def add_axes(self, *args, **kwargs): | |||
| 916 | 916 | ||
| 917 | 917 | self._axstack.add(key, a) | |
| 918 | 918 | self.sca(a) | |
| 919 | - a._remove_method = lambda ax: self.delaxes(ax) | ||
| 919 | + a._remove_method = self.__remove_ax | ||
| 920 | 920 | self.stale = True | |
| 921 | 921 | a.stale_callback = _stale_figure_callback | |
| 922 | 922 | return a | |
@@ -1006,11 +1006,37 @@ def add_subplot(self, *args, **kwargs): | |||
| 1006 | 1006 | ||
| 1007 | 1007 | self._axstack.add(key, a) | |
| 1008 | 1008 | self.sca(a) | |
| 1009 | - a._remove_method = lambda ax: self.delaxes(ax) | ||
| 1009 | + a._remove_method = self.__remove_ax | ||
| 1010 | 1010 | self.stale = True | |
| 1011 | 1011 | a.stale_callback = _stale_figure_callback | |
| 1012 | 1012 | return a | |
| 1013 | 1013 | ||
| 1014 | + def __remove_ax(self, ax): | ||
| 1015 | + def _reset_loc_form(axis): | ||
| 1016 | + axis.set_major_formatter(axis.get_major_formatter()) | ||
| 1017 | + axis.set_major_locator(axis.get_major_locator()) | ||
| 1018 | + axis.set_minor_formatter(axis.get_minor_formatter()) | ||
| 1019 | + axis.set_minor_locator(axis.get_minor_locator()) | ||
| 1020 | + | ||
| 1021 | + def _break_share_link(ax, grouper): | ||
| 1022 | + siblings = grouper.get_siblings(ax) | ||
| 1023 | + if len(siblings) > 1: | ||
| 1024 | + grouper.remove(ax) | ||
| 1025 | + for last_ax in siblings: | ||
| 1026 | + if ax is last_ax: | ||
| 1027 | + continue | ||
| 1028 | + return last_ax | ||
| 1029 | + return None | ||
| 1030 | + | ||
| 1031 | + self.delaxes(ax) | ||
| 1032 | + last_ax = _break_share_link(ax, ax._shared_y_axes) | ||
| 1033 | + if last_ax is not None: | ||
| 1034 | + _reset_loc_form(last_ax.yaxis) | ||
| 1035 | + | ||
| 1036 | + last_ax = _break_share_link(ax, ax._shared_x_axes) | ||
| 1037 | + if last_ax is not None: | ||
| 1038 | + _reset_loc_form(last_ax.xaxis) | ||
| 1039 | + | ||
| 1014 | 1040 | def clf(self, keep_observers=False): | |
| 1015 | 1041 | """ | |
| 1016 | 1042 | Clear the figure. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4191,6 +4191,51 @@ def test_axes_margins(): | |||
| 4191 | 4191 | assert ax.get_ybound() == (-0.5, 9.5) | |
| 4192 | 4192 | ||
| 4193 | 4193 | ||
| 4194 | + @cleanup | ||
| 4195 | + def test_remove_shared_axes(): | ||
| 4196 | + | ||
| 4197 | + def _helper_x(ax): | ||
| 4198 | + ax2 = ax.twinx() | ||
| 4199 | + ax2.remove() | ||
| 4200 | + ax.set_xlim(0, 15) | ||
| 4201 | + r = ax.xaxis.get_major_locator()() | ||
| 4202 | + assert r[-1] > 14 | ||
| 4203 | + | ||
| 4204 | + def _helper_y(ax): | ||
| 4205 | + ax2 = ax.twiny() | ||
| 4206 | + ax2.remove() | ||
| 4207 | + ax.set_ylim(0, 15) | ||
| 4208 | + r = ax.yaxis.get_major_locator()() | ||
| 4209 | + assert r[-1] > 14 | ||
| 4210 | + | ||
| 4211 | + # test all of the ways to get fig/ax sets | ||
| 4212 | + fig = plt.figure() | ||
| 4213 | + ax = fig.gca() | ||
| 4214 | + yield _helper_x, ax | ||
| 4215 | + yield _helper_y, ax | ||
| 4216 | + | ||
| 4217 | + fig, ax = plt.subplots() | ||
| 4218 | + yield _helper_x, ax | ||
| 4219 | + yield _helper_y, ax | ||
| 4220 | + | ||
| 4221 | + fig, ax_lst = plt.subplots(2, 2, sharex='all', sharey='all') | ||
| 4222 | + ax = ax_lst[0][0] | ||
| 4223 | + yield _helper_x, ax | ||
| 4224 | + yield _helper_y, ax | ||
| 4225 | + | ||
| 4226 | + fig = plt.figure() | ||
| 4227 | + ax = fig.add_axes([.1, .1, .8, .8]) | ||
| 4228 | + yield _helper_x, ax | ||
| 4229 | + yield _helper_y, ax | ||
| 4230 | + | ||
| 4231 | + fig, ax_lst = plt.subplots(2, 2, sharex='all', sharey='all') | ||
| 4232 | + ax = ax_lst[0][0] | ||
| 4233 | + orig_xlim = ax_lst[0][1].get_xlim() | ||
| 4234 | + ax.remove() | ||
| 4235 | + ax.set_xlim(0, 5) | ||
| 4236 | + assert assert_array_equal(ax_lst[0][1].get_xlim(), orig_xlim) | ||
| 4237 | + | ||
| 4238 | + | ||
| 4194 | 4239 | if __name__ == '__main__': | |
| 4195 | 4240 | import nose | |
| 4196 | 4241 | import sys | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,7 @@ | |||
| 1 | 1 | from __future__ import (absolute_import, division, print_function, | |
| 2 | 2 | unicode_literals) | |
| 3 | + import itertools | ||
| 4 | + from weakref import ref | ||
| 3 | 5 | ||
| 4 | 6 | from matplotlib.externals import six | |
| 5 | 7 | ||
@@ -376,3 +378,40 @@ def test_step_fails(): | |||
| 376 | 378 | np.arange(12)) | |
| 377 | 379 | assert_raises(ValueError, cbook._step_validation, | |
| 378 | 380 | np.arange(12), np.arange(3)) | |
| 381 | + | ||
| 382 | + | ||
| 383 | + def test_grouper(): | ||
| 384 | + class dummy(): | ||
| 385 | + pass | ||
| 386 | + a, b, c, d, e = objs = [dummy() for j in range(5)] | ||
| 387 | + g = cbook.Grouper() | ||
| 388 | + g.join(*objs) | ||
| 389 | + assert set(list(g)[0]) == set(objs) | ||
| 390 | + assert set(g.get_siblings(a)) == set(objs) | ||
| 391 | + | ||
| 392 | + for other in objs[1:]: | ||
| 393 | + assert g.joined(a, other) | ||
| 394 | + | ||
| 395 | + g.remove(a) | ||
| 396 | + for other in objs[1:]: | ||
| 397 | + assert not g.joined(a, other) | ||
| 398 | + | ||
| 399 | + for A, B in itertools.product(objs[1:], objs[1:]): | ||
| 400 | + assert g.joined(A, B) | ||
| 401 | + | ||
| 402 | + | ||
| 403 | + def test_grouper_private(): | ||
| 404 | + class dummy(): | ||
| 405 | + pass | ||
| 406 | + objs = [dummy() for j in range(5)] | ||
| 407 | + g = cbook.Grouper() | ||
| 408 | + g.join(*objs) | ||
| 409 | + # reach in and touch the internals ! | ||
| 410 | + mapping = g._mapping | ||
| 411 | + | ||
| 412 | + for o in objs: | ||
| 413 | + assert ref(o) in mapping | ||
| 414 | + | ||
| 415 | + base_set = mapping[ref(objs[0])] | ||
| 416 | + for o in objs[1:]: | ||
| 417 | + assert mapping[ref(o)] is base_set | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,7 @@ | |||
| 10 | 10 | from nose.tools import assert_raises, assert_equal | |
| 11 | 11 | from matplotlib.testing.decorators import image_comparison | |
| 12 | 12 | import matplotlib.pyplot as plt | |
| 13 | + from matplotlib import transforms | ||
| 13 | 14 | ||
| 14 | 15 | ||
| 15 | 16 | def test_readonly_path(): | |
@@ -113,6 +114,41 @@ def test_marker_paths_pdf(): | |||
| 113 | 114 | plt.ylim(-1, 7) | |
| 114 | 115 | ||
| 115 | 116 | ||
| 117 | + def test_path_no_doubled_point_in_to_polygon(): | ||
| 118 | + hand = np.array( | ||
| 119 | + [[1.64516129, 1.16145833], | ||
| 120 | + [1.64516129, 1.59375], | ||
| 121 | + [1.35080645, 1.921875], | ||
| 122 | + [1.375, 2.18229167], | ||
| 123 | + [1.68548387, 1.9375], | ||
| 124 | + [1.60887097, 2.55208333], | ||
| 125 | + [1.68548387, 2.69791667], | ||
| 126 | + [1.76209677, 2.56770833], | ||
| 127 | + [1.83064516, 1.97395833], | ||
| 128 | + [1.89516129, 2.75], | ||
| 129 | + [1.9516129, 2.84895833], | ||
| 130 | + [2.01209677, 2.76041667], | ||
| 131 | + [1.99193548, 1.99479167], | ||
| 132 | + [2.11290323, 2.63020833], | ||
| 133 | + [2.2016129, 2.734375], | ||
| 134 | + [2.25403226, 2.60416667], | ||
| 135 | + [2.14919355, 1.953125], | ||
| 136 | + [2.30645161, 2.36979167], | ||
| 137 | + [2.39112903, 2.36979167], | ||
| 138 | + [2.41532258, 2.1875], | ||
| 139 | + [2.1733871, 1.703125], | ||
| 140 | + [2.07782258, 1.16666667]]) | ||
| 141 | + | ||
| 142 | + (r0, c0, r1, c1) = (1.0, 1.5, 2.1, 2.5) | ||
| 143 | + | ||
| 144 | + poly = Path(np.vstack((hand[:, 1], hand[:, 0])).T, closed=True) | ||
| 145 | + clip_rect = transforms.Bbox([[r0, c0], [r1, c1]]) | ||
| 146 | + poly_clipped = poly.clip_to_bbox(clip_rect).to_polygons()[0] | ||
| 147 | + | ||
| 148 | + assert np.all(poly_clipped[-2] != poly_clipped[-1]) | ||
| 149 | + assert np.all(poly_clipped[-1] == poly_clipped[0]) | ||
| 150 | + | ||
| 151 | + | ||
| 116 | 152 | if __name__ == '__main__': | |
| 117 | 153 | import nose | |
| 118 | 154 | nose.runmodule(argv=['-s', '--with-doctest'], exit=False) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments