MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / draw_path

Method draw_path

lib/matplotlib/backends/backend_agg.py:95–173  ·  view source on GitHub ↗
(self, gc, path, transform, rgbFace=None)

Source from the content-addressed store, hash-verified

93 self.copy_from_bbox = self._renderer.copy_from_bbox
94
95 def draw_path(self, gc, path, transform, rgbFace=None):
96 # docstring inherited
97 nmax = mpl.rcParams['agg.path.chunksize'] # here at least for testing
98 npts = path.vertices.shape[0]
99
100 if (npts > nmax > 100 and path.should_simplify and
101 rgbFace is None and gc.get_hatch() is None):
102 nch = np.ceil(npts / nmax)
103 chsize = int(np.ceil(npts / nch))
104 i0 = np.arange(0, npts, chsize)
105 i1 = np.zeros_like(i0)
106 i1[:-1] = i0[1:] - 1
107 i1[-1] = npts
108 for ii0, ii1 in zip(i0, i1):
109 v = path.vertices[ii0:ii1, :]
110 c = path.codes
111 if c is not None:
112 c = c[ii0:ii1]
113 c[0] = Path.MOVETO # move to end of last chunk
114 p = Path(v, c)
115 p.simplify_threshold = path.simplify_threshold
116 try:
117 self._renderer.draw_path(gc, p, transform, rgbFace)
118 except OverflowError:
119 msg = (
120 "Exceeded cell block limit in Agg.\n\n"
121 "Please reduce the value of "
122 f"rcParams['agg.path.chunksize'] (currently {nmax}) "
123 "or increase the path simplification threshold"
124 "(rcParams['path.simplify_threshold'] = "
125 f"{mpl.rcParams['path.simplify_threshold']:.2f} by "
126 "default and path.simplify_threshold = "
127 f"{path.simplify_threshold:.2f} on the input)."
128 )
129 raise OverflowError(msg) from None
130 else:
131 try:
132 self._renderer.draw_path(gc, path, transform, rgbFace)
133 except OverflowError:
134 cant_chunk = ''
135 if rgbFace is not None:
136 cant_chunk += "- cannot split filled path\n"
137 if gc.get_hatch() is not None:
138 cant_chunk += "- cannot split hatched path\n"
139 if not path.should_simplify:
140 cant_chunk += "- path.should_simplify is False\n"
141 if len(cant_chunk):
142 msg = (
143 "Exceeded cell block limit in Agg, however for the "
144 "following reasons:\n\n"
145 f"{cant_chunk}\n"
146 "we cannot automatically split up this path to draw."
147 "\n\nPlease manually simplify your path."
148 )
149
150 else:
151 inc_threshold = (
152 "or increase the path simplification threshold"

Callers 2

test_chunksize_failsFunction · 0.95

Calls 2

PathClass · 0.90
get_hatchMethod · 0.45

Tested by 1

test_chunksize_failsFunction · 0.76