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

Skip to content

Commit af07100

Browse files
committed
Merge pull request #1964 from cimarronm/data_spine_right_top_location_fix
Fixes issue #1960. Account for right/top spine data offset on transform ...
2 parents 1f07cb8 + 6f45b43 commit af07100

6 files changed

Lines changed: 564 additions & 0 deletions

File tree

doc/api/api_changes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ For new features that were added to matplotlib, please see
1515
Changes in 1.3.x
1616
================
1717

18+
* Fixed a bug in setting the position for the right/top spine with data
19+
position type. Previously, it would draw the right or top spine at
20+
+1 data offset.
21+
1822
* In :class:`~matplotlib.patches.FancyArrow`, the default arrow head width,
1923
``head_width``, has been made larger to produce a visible arrow head. The new
2024
value of this kwarg is ``head_width = 20 * width``.

lib/matplotlib/spines.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ def _calc_offset_transform(self):
323323
self._spine_transform = ('identity',
324324
mtransforms.IdentityTransform())
325325
elif position_type == 'data':
326+
if self.spine_type in ('right', 'top'):
327+
# The right and top spines have a default position of 1 in
328+
# axes coordinates. When specifying the position in data
329+
# coordinates, we need to calculate the position relative to 0.
330+
amount -= 1
326331
if self.spine_type in ('left', 'right'):
327332
self._spine_transform = ('data',
328333
mtransforms.Affine2D().translate(
Binary file not shown.
13.5 KB
Loading

0 commit comments

Comments
 (0)