MCPcopy
hub / github.com/dask/dask / svg_lines

Function svg_lines

dask/array/svg.py:180–205  ·  view source on GitHub ↗

Convert points into lines of text for an SVG plot Examples -------- >>> svg_lines([0, 1], [0, 0], [10, 11], [1, 1]) # doctest: +NORMALIZE_WHITESPACE [' ', ' <line x1="1" y1="0" x2="11" y2="1" style="stroke-width:2"

(x1, y1, x2, y2, max_n=20)

Source from the content-addressed store, hash-verified

178
179
180def svg_lines(x1, y1, x2, y2, max_n=20):
181 """Convert points into lines of text for an SVG plot
182
183 Examples
184 --------
185 >>> svg_lines([0, 1], [0, 0], [10, 11], [1, 1]) # doctest: +NORMALIZE_WHITESPACE
186 [' <line x1="0" y1="0" x2="10" y2="1" style="stroke-width:2" />',
187 ' <line x1="1" y1="0" x2="11" y2="1" style="stroke-width:2" />']
188 """
189 n = len(x1)
190
191 if n > max_n:
192 indices = np.linspace(0, n - 1, max_n, dtype="int")
193 else:
194 indices = range(n)
195
196 lines = [
197 ' <line x1="{}" y1="{}" x2="{}" y2="{}" />'.format(
198 int(x1[i]), int(y1[i]), int(x2[i]), int(y2[i])
199 )
200 for i in indices
201 ]
202
203 lines[0] = lines[0].replace(" /", ' style="stroke-width:2" /')
204 lines[-1] = lines[-1].replace(" /", ' style="stroke-width:2" /')
205 return lines
206
207
208def svg_grid(x, y, offset=(0, 0), skew=(0, 0), size=200):

Callers 1

svg_gridFunction · 0.85

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…