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

Skip to content

Commit c4b9b9b

Browse files
pelsonmdboom
authored andcommitted
Updated ContourSet api to make transform private (in favour of using a get_transform method).
1 parent 4e80cc5 commit c4b9b9b

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

doc/api/api_changes.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ Changes in 1.2.x
114114
>>> print(ax.viewLim)
115115
Bbox('array([[ 0., 0.],\n [ 90., 90.]])')
116116

117-
* One can now easily get a transform which goes from one transform's coordinate system
118-
to another, in an optimized way, using the new subtract method on a transform. For instance,
119-
to go from data coordinates to axes coordinates::
117+
* One can now easily get a transform which goes from one transform's coordinate
118+
system to another, in an optimized way, using the new subtract method on a
119+
transform. For instance, to go from data coordinates to axes coordinates::
120120

121121
>>> import matplotlib.pyplot as plt
122122
>>> ax = plt.axes()
@@ -126,9 +126,9 @@ Changes in 1.2.x
126126
>>> print(data2ax.depth)
127127
2
128128

129-
for versions before 1.2 this could only be achieved in a sub-optimal way, using
130-
``ax.transData + ax.transAxes.inverted()`` (depth is a new concept, but had it existed
131-
it would return 4 for this example).
129+
for versions before 1.2 this could only be achieved in a sub-optimal way,
130+
using ``ax.transData + ax.transAxes.inverted()`` (depth is a new concept,
131+
but had it existed it would return 4 for this example).
132132

133133
* ``twinx`` and ``twiny`` now returns an instance of SubplotBase if
134134
parent axes is an instance of SubplotBase.
@@ -141,6 +141,9 @@ Changes in 1.2.x
141141
* :class:`~matplotlib.colors.ColorConverter`,
142142
:class:`~matplotlib.colors.Colormap` and
143143
:class:`~matplotlib.colors.Normalize` now subclasses ``object``
144+
145+
* ContourSet instances no longer have a ``transform`` attribute. Instead,
146+
access the transform with the ``get_transform`` method.
144147

145148
Changes in 1.1.x
146149
================

lib/matplotlib/contour.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ def __init__(self, ax, *args, **kwargs):
775775
raise ValueError('Either colors or cmap must be None')
776776
if self.origin == 'image': self.origin = mpl.rcParams['image.origin']
777777

778-
self.transform = kwargs.get('transform', None)
778+
self._transform = kwargs.get('transform', None)
779779

780780
self._process_args(*args, **kwargs)
781781
self._process_levels()
@@ -857,12 +857,12 @@ def get_transform(self):
857857
Return the :class:`~matplotlib.transforms.Transform`
858858
instance used by this ContourSet.
859859
"""
860-
if self.transform is None:
861-
self.transform = self.ax.transData
862-
elif (not isinstance(self.transform, mtrans.Transform)
863-
and hasattr(self.transform, '_as_mpl_transform')):
864-
self.transform = self.transform._as_mpl_transform(self.ax)
865-
return self.transform
860+
if self._transform is None:
861+
self._transform = self.ax.transData
862+
elif (not isinstance(self._transform, mtrans.Transform)
863+
and hasattr(self._transform, '_as_mpl_transform')):
864+
self._transform = self._transform._as_mpl_transform(self.ax)
865+
return self._transform
866866

867867
def __getstate__(self):
868868
state = self.__dict__.copy()

0 commit comments

Comments
 (0)