10000 Add properties in addition to get/set · matplotlib/matplotlib@b68950c · GitHub
[go: up one dir, main page]

Skip to content

Commit b68950c

Browse files
committed
Add properties in addition to get/set
1 parent 0e0c005 commit b68950c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/matplotlib/artist.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,8 @@ def set_top_margin(self, margin):
914914
self.stale = True
915915
self._margins['top'] = margin
916916

917+
top_margin = property(get_top_margin, set_top_margin)
918+
917919
def get_bottom_margin(self):
918920
"""
919921
Get whether a margin should be applied to the bottom of the Artist.
@@ -928,6 +930,8 @@ def set_bottom_margin(self, margin):
928930
self.stale = True
929931
self._margins['bottom'] = margin
930932

933+
bottom_margin = property(get_bottom_margin, set_bottom_margin)
934+
931935
def get_left_margin(self):
932936
"""
933937
Get whether a margin should be applied to the left of the Artist.
@@ -942,6 +946,8 @@ def set_left_margin(self, margin):
942946
self.stale = True
943947
self._margins['left'] = margin
944948

949+
left_margin = property(get_left_margin, set_left_margin)
950+
945951
def get_right_margin(self):
946952
"""
947953
Get whether a margin should be applied to the right of the Artist.
@@ -956,6 +962,8 @@ def set_right_margin(self, margin):
956962
self.stale = True
957963
self._margins['right'] = margin
958964

965+
right_margin = property(get_right_margin, set_right_margin)
966+
959967
def get_margins(self):
960968
"""
961969
Returns a dictionary describing whether a margin should be applied on
@@ -983,6 +991,8 @@ def set_margins(self, margins):
983991

984992
self._margins = margins
985993

994+
margins = property(get_margins, set_margins)
995+
986996
def update_from(self, other):
987997
'Copy properties from *other* to *self*.'
988998
self._transform = other._transform

lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,7 +2155,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
21552155
for artist_set in [self.collections, self.patches, self.lines,
21562156
self.artists, self.images]:
21572157
for artist in artist_set:
2158-
artist_margins = artist.get_margins()
2158+
artist_margins = artist.margins
21592159
for key in ['left', 'right', 'top', 'bottom']:
21602160
margins[key] &= artist_margins.get(key, True)
21612161

@@ -2164,7 +2164,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
21642164
for artist_set in [axes.collections, axes.patches,
21652165
axes.lines, axes.artists, axes.images]:
21662166
for artist in artist_set:
2167-
artist_margins = artist.get_margins()
2167+
artist_margins = artist.margins
21682168
for key in ['left', 'right']:
21692169
margins[key] &= artist_margins.get(key, True)
21702170

@@ -2173,7 +2173,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
21732173
for artist_set in [axes.collections, axes.patches,
21742174
axes.lines, axes.artists, axes.images]:
21752175
for artist in artist_set:
2176-
artist_margins = artist.get_margins()
2176+
artist_margins = artist.margins
21772177
for key in ['top', 'bottom']:
21782178
margins[key] &= artist_margins.get(key, True)
21792179
else:

0 commit comments

Comments
 (0)
0