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

Skip to content

Commit 245e710

Browse files
committed
minor refactor
1 parent 9acc86d commit 245e710

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,8 @@ def set_snap(self, snap):
936936
"""
937937
self._snap = snap
938938

939-
def set_hatch_scale(self, scale):
940-
self._hatch_scale = scale
939+
def set_hatch_buffer_scale(self, scale):
940+
self._hatch_buffer_scale = scale
941941

942942
def set_hatch(self, hatch):
943943
"""Set the hatch style (for fills)."""
@@ -950,7 +950,7 @@ def get_hatch(self):
950950
def get_hatch_path(self, density=6.0):
951951
"""Return a `.Path` for the current hatch."""
952952
if len(self.get_hatchstyles()):
953-
return Path.hatchstyles(self.get_hatchstyles(), self._hatch_scale)
953+
return Path.hatchstyles(self.get_hatchstyles(), self._hatch_buffer_scale)
954954
hatch = self.get_hatch()
955955
if hatch is None:
956956
return None

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def draw_path(self, gc, path, transform, rgbFace=None):
105105
# docstring inherited
106106
nmax = mpl.rcParams['agg.path.chunksize'] # here at least for testing
107107
npts = path.vertices.shape[0]
108-
gc.set_hatch_scale(self.hatch_buffer_size / self.dpi)
108+
gc.set_hatch_buffer_scale(self.hatch_buffer_size / self.dpi)
109109

110110
if (npts > nmax > 100 and path.should_simplify and
111111
rgbFace is None and gc.get_hatch() is None):

lib/matplotlib/hatch.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ def rotate_vertices(self, vertices, angle=None, scale_correction=True):
268268
vertices += center
269269
return vertices
270270

271-
def get_vertices_and_codes(self, hatch_scale=1):
272-
self.hatch_scale = hatch_scale
271+
def get_vertices_and_codes(self, hatch_buffer_scale=1.0):
272+
self.hatch_buffer_scale = hatch_buffer_scale
273273
vertices, codes = np.empty((0, 2)), np.empty(0, Path.code_type)
274274

275275
if self.hatchpattern in hatchpatterns:
@@ -320,7 +320,7 @@ def _get_marker_path(marker):
320320
def marker_pattern(hatchstyle):
321321
size = hatchstyle.kwargs['weight']
322322
num_rows = round(
323-
hatchstyle.kwargs['scale'] * hatchstyle.hatch_scale
323+
hatchstyle.kwargs['scale'] * hatchstyle.hatch_buffer_scale
324324
)
325325
path = MarkerHatchStyle._get_marker_path(hatchstyle.hatchpattern)
326326
marker_vertices = hatchstyle.rotate_vertices(
@@ -370,7 +370,7 @@ def marker_pattern(hatchstyle):
370370
class LineHatchStyle(HatchStyle):
371371
def horizontal(hatchstyle):
372372
num_lines = round(
373-
hatchstyle.kwargs['scale'] * hatchstyle.hatch_scale
373+
hatchstyle.kwargs['scale'] * hatchstyle.hatch_buffer_scale
374374
)
375375
if num_lines:
376376
num_vertices = num_lines * 2
@@ -392,7 +392,7 @@ def horizontal(hatchstyle):
392392

393393
def vertical(hatchstyle):
394394
num_lines = round(
395-
hatchstyle.kwargs['scale'] * hatchstyle.hatch_scale
395+
hatchstyle.kwargs['scale'] * hatchstyle.hatch_buffer_scale
396396
)
397397
if num_lines:
398398
num_vertices = num_lines * 2
@@ -414,7 +414,7 @@ def vertical(hatchstyle):
414414

415415
def north_east(hatchstyle):
416416
num_lines = round(
417-
hatchstyle.kwargs['scale'] * hatchstyle.hatch_scale
417+
hatchstyle.kwargs['scale'] * hatchstyle.hatch_buffer_scale
418418
)
419419
if num_lines:
420420
num_vertices = (num_lines + 1) * 2
@@ -435,7 +435,7 @@ def north_east(hatchstyle):
435435

436436
def south_east(hatchstyle):
437437
num_lines = round(
438-
hatchstyle.kwargs['scale'] * hatchstyle.hatch_scale
438+
hatchstyle.kwargs['scale'] * hatchstyle.hatch_buffer_scale
439439
)
440440
if num_lines:
441441
num_vertices = (num_lines + 1) * 2

lib/matplotlib/path.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,10 +1037,10 @@ def hatch(hatchpattern, density=6):
10371037
return (get_path(hatchpattern, density)
10381038
if hatchpattern is not None else None)
10391039

1040-
def hatchstyles(hatchstyles, hatch_scale=1):
1040+
def hatchstyles(hatchstyles, hatch_buffer_scale=1.0):
10411041
vertices, codes = np.empty((0, 2)), np.empty(0, Path.code_type)
10421042
for hatchstyle in hatchstyles:
1043-
verts, cods = hatchstyle.get_vertices_and_codes(hatch_scale)
1043+
verts, cods = hatchstyle.get_vertices_and_codes(hatch_buffer_scale)
10441044
vertices = np.concatenate([vertices, verts])
10451045
codes = np.concatenate([codes, cods])
10461046
return Path(vertices, codes)

0 commit comments

Comments
 (0)