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

Skip to content

Commit e4d0f08

Browse files
committed
Replace hand-creation of blended transforms in Axes.
By default get_[x|y]axis_transform() do the same, but by calling these methods instead of creating the transforms by hand, we better support custom Axes.
1 parent da0dce4 commit e4d0f08

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -720,8 +720,7 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
720720
yy = self.convert_yunits(y)
721721
scaley = (yy < ymin) or (yy > ymax)
722722

723-
trans = mtransforms.blended_transform_factory(
724-
self.transAxes, self.transData)
723+
trans = self.get_yaxis_transform(which='grid')
725724
l = mlines.Line2D([xmin, xmax], [y, y], transform=trans, **kwargs)
726725
self.add_line(l)
727726
self.autoscale_view(scalex=False, scaley=scaley)
@@ -787,8 +786,7 @@ def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
787786
xx = self.convert_xunits(x)
788787
scalex = (xx < xmin) or (xx > xmax)
789788

790-
trans = mtransforms.blended_transform_factory(
791-
self.transData, self.transAxes)
789+
trans = self.get_xaxis_transform(which='grid')
792790
l = mlines.Line2D([x, x], [ymin, ymax], transform=trans, **kwargs)
793791
self.add_line(l)
794792
self.autoscale_view(scalex=scalex, scaley=False)
@@ -833,8 +831,7 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
833831
.. plot:: mpl_examples/pylab_examples/axhspan_demo.py
834832
835833
"""
836-
trans = mtransforms.blended_transform_factory(
837-
self.transAxes, self.transData)
834+
trans = self.get_yaxis_transform(which='grid')
838835

839836
# process the unit information
840837
self._process_unit_info([xmin, xmax], [ymin, ymax], kwargs=kwargs)
@@ -889,8 +886,7 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
889886
:meth:`axhspan`
890887
for example plot and source code
891888
"""
892-
trans = mtransforms.blended_transform_factory(
893-
self.transData, self.transAxes)
889+
trans = self.get_xaxis_transform(which='grid')
894890

895891
# process the unit information
896892
self._process_unit_info([xmin, xmax], [ymin, ymax], kwargs=kwargs)
@@ -3949,8 +3945,7 @@ def coarse_bin(x, y, coarse):
39493945
values.append(val)
39503946

39513947
values = np.array(values)
3952-
trans = mtransforms.blended_transform_factory(
3953-
self.transData, self.transAxes)
3948+
trans = self.get_xaxis_transform(which='grid')
39543949

39553950
hbar = mcoll.PolyCollection(verts, transform=trans, edgecolors='face')
39563951

@@ -3979,8 +3974,7 @@ def coarse_bin(x, y, coarse):
39793974

39803975
values = np.array(values)
39813976

3982-
trans = mtransforms.blended_transform_factory(
3983-
self.transAxes, self.transData)
3977+
trans = self.get_yaxis_transform(which='grid')
39843978

39853979
vbar = mcoll.PolyCollection(verts, transform=trans, edgecolors='face')
39863980
vbar.set_array(values)

0 commit comments

Comments
 (0)