Skip to content

Commit 6d42e0a

Browse files
committed
Merge 'v1.5.x' into 'v2.x'
Conflicts: lib/matplotlib/tests/test_axes.py test added on both branches, kept all lib/mpl_toolkits/tests/test_axes_grid1.py test vs white space, trivial resolution setup.py conflicts between freetype building work and reverting setup.py test
2 parents 16f4895 + 6b30aaa commit 6d42e0a

File tree

20 files changed

+1131
-224
lines changed

20 files changed

+1131
-224
lines changed

doc/_static/logo2.png

-26.6 KB
Binary file not shown.

doc/_static/logo2.svg

Lines changed: 520 additions & 0 deletions
Loading

doc/_templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ <h3>We're updating the default styles for Matplotlib 2.0</h3>
196196

197197
<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px">
198198
<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>
200200
</div>
201201

202202
{% endblock %}

doc/mpl_toolkits/axes_grid/api/index.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@
1313
axes_divider_api.rst
1414
axes_grid_api.rst
1515
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
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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:

lib/matplotlib/cbook.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,7 @@ class Grouper(object):
16561656
False
16571657
16581658
"""
1659-
def __init__(self, init=[]):
1659+
def __init__(self, init=()):
16601660
mapping = self._mapping = {}
16611661
for x in init:
16621662
mapping[ref(x)] = [ref(x)]
@@ -1708,6 +1708,14 @@ def joined(self, a, b):
17081708
except KeyError:
17091709
return False
17101710

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+
17111719
def __iter__(self):
17121720
"""
17131721
Iterate over each of the disjoint sets as a list.

lib/matplotlib/figure.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ def add_axes(self, *args, **kwargs):
916916

917917
self._axstack.add(key, a)
918918
self.sca(a)
919-
a._remove_method = lambda ax: self.delaxes(ax)
919+
a._remove_method = self.__remove_ax
920920
self.stale = True
921921
a.stale_callback = _stale_figure_callback
922922
return a
@@ -1006,11 +1006,37 @@ def add_subplot(self, *args, **kwargs):
10061006

10071007
self._axstack.add(key, a)
10081008
self.sca(a)
1009-
a._remove_method = lambda ax: self.delaxes(ax)
1009+
a._remove_method = self.__remove_ax
10101010
self.stale = True
10111011
a.stale_callback = _stale_figure_callback
10121012
return a
10131013

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+
10141040
def clf(self, keep_observers=False):
10151041
"""
10161042
Clear the figure.

lib/matplotlib/tests/test_axes.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4191,6 +4191,51 @@ def test_axes_margins():
41914191
assert ax.get_ybound() == (-0.5, 9.5)
41924192

41934193

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+
41944239
if __name__ == '__main__':
41954240
import nose
41964241
import sys

lib/matplotlib/tests/test_cbook.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
3+
import itertools
4+
from weakref import ref
35

46
from matplotlib.externals import six
57

@@ -376,3 +378,40 @@ def test_step_fails():
376378
np.arange(12))
377379
assert_raises(ValueError, cbook._step_validation,
378380
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

lib/matplotlib/tests/test_path.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from nose.tools import assert_raises, assert_equal
1111
from matplotlib.testing.decorators import image_comparison
1212
import matplotlib.pyplot as plt
13+
from matplotlib import transforms
1314

1415

1516
def test_readonly_path():
@@ -113,6 +114,41 @@ def test_marker_paths_pdf():
113114
plt.ylim(-1, 7)
114115

115116

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+
116152
if __name__ == '__main__':
117153
import nose
118154
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def onselect(epress, erelease):
162162
extents = [int(e) for e in tool.extents]
163163
assert extents == [70, 129, 70, 130], extents
164164

165-
assert tool.geometry.shape == (2, 74)
165+
assert tool.geometry.shape == (2, 73)
166166
assert_allclose(tool.geometry[:, 0], [70., 100])
167167

168168

lib/matplotlib/ticker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ def set_offset_string(self, ofs):
322322
class FuncFormatter(Formatter):
323323
"""
324324
User defined function for formatting
325+
326+
The function should take in two inputs (tick value *x* and position *pos*)
327+
and return a string
325328
"""
326329
def __init__(self, func):
327330
self.func = func

lib/matplotlib/widgets.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def on_clicked(self, func):
245245
"""
246246
When the button is clicked, call this *func* with event.
247247
248-
A connection id is returned. It can be used to disconnect
248+
A connection id is returned. It can be used to disconnect
249249
the button from its callback.
250250
"""
251251
cid = self.cnt
@@ -265,7 +265,7 @@ class Slider(AxesWidget):
265265
"""
266266
A slider representing a floating point range.
267267
268-
For the slider to remain responsive you must maintain a
268+
For the slider to remain responsive you must maintain a
269269
reference to it.
270270
271271
The following attributes are defined
@@ -1473,6 +1473,7 @@ def new_axes(self, ax):
14731473
transform=trans,
14741474
visible=False,
14751475
**self.rectprops)
1476+
self.stay_rect.set_animated(False)
14761477
self.ax.add_patch(self.stay_rect)
14771478

14781479
self.ax.add_patch(self.rect)
@@ -1487,7 +1488,10 @@ def _press(self, event):
14871488
self.rect.set_visible(self.visible)
14881489
if self.span_stays:
14891490
self.stay_rect.set_visible(False)
1490-
1491+
# really force a draw so that the stay rect is not in
1492+
# the blit background
1493+
if self.useblit:
1494+
self.canvas.draw()
14911495
xdata, ydata = self._get_data(event)
14921496
if self.direction == 'horizontal':
14931497
self.pressv = xdata
@@ -1510,7 +1514,7 @@ def _release(self, event):
15101514
self.stay_rect.set_height(self.rect.get_height())
15111515
self.stay_rect.set_visible(True)
15121516

1513-
self.canvas.draw()
1517+
self.canvas.draw_idle()
15141518
vmin = self.pressv
15151519
xdata, ydata = self._get_data(event)
15161520
if self.direction == 'horizontal':
@@ -2036,7 +2040,7 @@ def geometry(self):
20362040
if hasattr(self.to_draw, 'get_verts'):
20372041
xfm = self.ax.transData.inverted()
20382042
y, x = xfm.transform(self.to_draw.get_verts()).T
2039-
return np.array([x[:-1], y[:-1]])
2043+
return np.array([x, y])
20402044
else:
20412045
return np.array(self.to_draw.get_data())
20422046

lib/mpl_toolkits/axes_grid1/colorbar.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,8 @@ def __init__(self, ax, cmap=None,
374374
if format is None:
375375
if isinstance(self.norm, colors.LogNorm):
376376
# change both axis for proper aspect
377-
self.ax.xaxis.set_scale("log")
378-
self.ax.yaxis.set_scale("log")
379-
self.ax._update_transScale()
377+
self.ax.set_xscale("log")
378+
self.ax.set_yscale("log")
380379
self.cbar_axis.set_minor_locator(ticker.NullLocator())
381380
formatter = ticker.LogFormatter()
382381
else:

0 commit comments

Comments
 (0)