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

Skip to content

Commit c11b096

Browse files
authored
Merge pull request #8338 from delftswa2017/axes_double_transform_import
Renamed all 'mtrans' into more common 'mtransforms'
2 parents 2063e81 + 5ca46ea commit c11b096

File tree

9 files changed

+86
-82
lines changed

9 files changed

+86
-82
lines changed

examples/pylab_examples/transoffset.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
'''
1717

1818
import matplotlib.pyplot as plt
19-
import matplotlib.transforms as mtrans
19+
import matplotlib.transforms as mtransforms
2020
import numpy as np
2121

2222
from matplotlib.transforms import offset_copy
@@ -31,8 +31,8 @@
3131
# we only need to make one transform. To get the
3232
# transform argument to offset_copy, we need to make the axes
3333
# first; the subplot command above is one way to do this.
34-
trans_offset = mtrans.offset_copy(ax.transData, fig=fig,
35-
x=0.05, y=0.10, units='inches')
34+
trans_offset = mtransforms.offset_copy(ax.transData, fig=fig,
35+
x=0.05, y=0.10, units='inches')
3636

3737
for x, y in zip(xs, ys):
3838
plt.plot((x,), (y,), 'ro')
@@ -42,7 +42,7 @@
4242
# offset_copy works for polar plots also.
4343
ax = plt.subplot(2, 1, 2, projection='polar')
4444

45-
trans_offset = mtrans.offset_copy(ax.transData, fig=fig, y=6, units='dots')
45+
trans_offset = mtransforms.offset_copy(ax.transData, fig=fig, y=6, units='dots')
4646

4747
for x, y in zip(xs, ys):
4848
plt.polar((x,), (y,), 'ro')

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import matplotlib.ticker as mticker
4141
import matplotlib.transforms as mtransforms
4242
import matplotlib.tri as mtri
43-
import matplotlib.transforms as mtrans
4443
from matplotlib.container import BarContainer, ErrorbarContainer, StemContainer
4544
from matplotlib.axes._base import _AxesBase
4645
from matplotlib.axes._base import _process_plot_format
@@ -4251,8 +4250,8 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
42514250
ymin, ymax = (np.min(y), np.max(y)) if len(y) else (0, 1)
42524251

42534252
# to avoid issues with singular data, expand the min/max pairs
4254-
xmin, xmax = mtrans.nonsingular(xmin, xmax, expander=0.1)
4255-
ymin, ymax = mtrans.nonsingular(ymin, ymax, expander=0.1)
4253+
xmin, xmax = mtransforms.nonsingular(xmin, xmax, expander=0.1)
4254+
ymin, ymax = mtransforms.nonsingular(ymin, ymax, expander=0.1)
42564255

42574256
# In the x-direction, the hexagons exactly cover the region from
42584257
# xmin to xmax. Need some padding to avoid roundoff errors.

lib/matplotlib/colorbar.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import matplotlib.patches as mpatches
4040
import matplotlib.path as mpath
4141
import matplotlib.ticker as ticker
42-
import matplotlib.transforms as mtrans
42+
import matplotlib.transforms as mtransforms
4343

4444
from matplotlib import docstring
4545

@@ -687,9 +687,10 @@ def _process_values(self, b=None):
687687
self.norm.vmin = 0
688688
self.norm.vmax = 1
689689

690-
self.norm.vmin, self.norm.vmax = mtrans.nonsingular(self.norm.vmin,
691-
self.norm.vmax,
692-
expander=0.1)
690+
self.norm.vmin, self.norm.vmax = mtransforms.nonsingular(
691+
self.norm.vmin,
692+
self.norm.vmax,
693+
expander=0.1)
693694

694695
b = self.norm.inverse(self._uniform_y(self.cmap.N + 1))
695696

@@ -1126,8 +1127,8 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
11261127
'parents share the same figure.')
11271128

11281129
# take a bounding box around all of the given axes
1129-
parents_bbox = mtrans.Bbox.union([ax.get_position(original=True).frozen()
1130-
for ax in parents])
1130+
parents_bbox = mtransforms.Bbox.union(
1131+
[ax.get_position(original=True).frozen() for ax in parents])
11311132

11321133
pb = parents_bbox
11331134
if location in ('left', 'right'):
@@ -1148,12 +1149,12 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
11481149

11491150
# define a transform which takes us from old axes coordinates to
11501151
# new axes coordinates
1151-
shrinking_trans = mtrans.BboxTransform(parents_bbox, pb1)
1152+
shrinking_trans = mtransforms.BboxTransform(parents_bbox, pb1)
11521153

11531154
# transform each of the axes in parents using the new transform
11541155
for ax in parents:
11551156
new_posn = shrinking_trans.transform(ax.get_position())
1156-
new_posn = mtrans.Bbox(new_posn)
1157+
new_posn = mtransforms.Bbox(new_posn)
11571158
ax.set_position(new_posn)
11581159
if parent_anchor is not False:
11591160
ax.set_anchor(parent_anchor)

lib/matplotlib/contour.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import matplotlib.mathtext as mathtext
2727
import matplotlib.patches as mpatches
2828
import matplotlib.texmanager as texmanager
29-
import matplotlib.transforms as mtrans
29+
import matplotlib.transforms as mtransforms
3030
from matplotlib.cbook import mplDeprecation
3131

3232
# Import needed for adding manual selection capability to clabel
@@ -967,7 +967,7 @@ def get_transform(self):
967967
"""
968968
if self._transform is None:
969969
self._transform = self.ax.transData
970-
elif (not isinstance(self._transform, mtrans.Transform)
970+
elif (not isinstance(self._transform, mtransforms.Transform)
971971
and hasattr(self._transform, '_as_mpl_transform')):
972972
self._transform = self._transform._as_mpl_transform(self.ax)
973973
return self._transform

lib/matplotlib/patheffects.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
import six
1111

1212
from matplotlib.backend_bases import RendererBase
13-
from matplotlib import (
14-
colors as mcolors, patches as mpatches, transforms as mtransforms)
13+
from matplotlib import colors as mcolors
14+
from matplotlib import patches as mpatches
15+
from matplotlib import transforms as mtransforms
1516

1617

1718
class AbstractPathEffect(object):

lib/matplotlib/tests/test_artist.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import matplotlib.patches as mpatches
1212
import matplotlib.lines as mlines
1313
import matplotlib.path as mpath
14-
import matplotlib.transforms as mtrans
14+
import matplotlib.transforms as mtransforms
1515
import matplotlib.collections as mcollections
1616
import matplotlib.artist as martist
1717
from matplotlib.testing.decorators import image_comparison
@@ -39,13 +39,13 @@ def test_patch_transform_of_none():
3939
transform=None, alpha=0.5)
4040
assert e.is_transform_set() is True
4141
ax.add_patch(e)
42-
assert isinstance(e._transform, mtrans.IdentityTransform)
42+
assert isinstance(e._transform, mtransforms.IdentityTransform)
4343

4444
# Providing an IdentityTransform puts the ellipse in device coordinates.
4545
e = mpatches.Ellipse(xy_pix, width=100, height=100,
46-
transform=mtrans.IdentityTransform(), alpha=0.5)
46+
transform=mtransforms.IdentityTransform(), alpha=0.5)
4747
ax.add_patch(e)
48-
assert isinstance(e._transform, mtrans.IdentityTransform)
48+
assert isinstance(e._transform, mtransforms.IdentityTransform)
4949

5050
# Not providing a transform, and then subsequently "get_transform" should
5151
# not mean that "is_transform_set".
@@ -84,14 +84,15 @@ def test_collection_transform_of_none():
8484
alpha=0.5)
8585
c.set_transform(None)
8686
ax.add_collection(c)
87-
assert isinstance(c.get_transform(), mtrans.IdentityTransform)
87+
assert isinstance(c.get_transform(), mtransforms.IdentityTransform)
8888

8989
# providing an IdentityTransform puts the ellipse in device coordinates
9090
e = mpatches.Ellipse(xy_pix, width=100, height=100)
91-
c = mcollections.PatchCollection([e], transform=mtrans.IdentityTransform(),
92-
alpha=0.5)
91+
c = mcollections.PatchCollection([e],
92+
transform=mtransforms.IdentityTransform(),
93+
alpha=0.5)
9394
ax.add_collection(c)
94-
assert isinstance(c._transOffset, mtrans.IdentityTransform)
95+
assert isinstance(c._transOffset, mtransforms.IdentityTransform)
9596

9697

9798
@image_comparison(baseline_images=["clip_path_clipping"], remove_text=True)

lib/matplotlib/tests/test_legend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from matplotlib.testing.decorators import image_comparison
1313
import matplotlib.pyplot as plt
1414
import matplotlib as mpl
15-
import matplotlib.transforms as mtrans
15+
import matplotlib.transforms as mtransforms
1616
import matplotlib.collections as mcollections
1717
from matplotlib.legend_handler import HandlerTuple
1818

@@ -293,7 +293,7 @@ def test_not_covering_scatter():
293293
extensions=['png'])
294294
def test_not_covering_scatter_transform():
295295
# Offsets point to top left, the default auto position
296-
offset = mtrans.Affine2D().translate(-20, 20)
296+
offset = mtransforms.Affine2D().translate(-20, 20)
297297
x = np.linspace(0, 30, 1000)
298298
plt.plot(x, x)
299299

lib/matplotlib/tests/test_patches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import matplotlib.patches as mpatches
1818
import matplotlib.collections as mcollections
1919
from matplotlib import path as mpath
20-
from matplotlib import transforms as mtrans
20+
from matplotlib import transforms as mtransforms
2121
import matplotlib.style as mstyle
2222

2323
import sys
@@ -113,7 +113,7 @@ def test_clip_to_bbox():
113113
combined, alpha=0.5, facecolor='coral', edgecolor='none')
114114
ax.add_patch(patch)
115115

116-
bbox = mtrans.Bbox([[-12, -77.5], [50, -110]])
116+
bbox = mtransforms.Bbox([[-12, -77.5], [50, -110]])
117117
result_path = combined.clip_to_bbox(bbox)
118118
result_patch = mpatches.PathPatch(
119119
result_path, alpha=0.5, facecolor='green', lw=4, edgecolor='black')

0 commit comments

Comments
 (0)