MCPcopy Create free account
hub / github.com/dask/dask / svg_lines

Function svg_lines

dask/array/svg.py:173–196  ·  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

171
172
173def svg_lines(x1, y1, x2, y2, max_n=20):
174 """Convert points into lines of text for an SVG plot
175
176 Examples
177 --------
178 >>> svg_lines([0, 1], [0, 0], [10, 11], [1, 1]) # doctest: +NORMALIZE_WHITESPACE
179 [' <line x1="0" y1="0" x2="10" y2="1" style="stroke-width:2" />',
180 ' <line x1="1" y1="0" x2="11" y2="1" style="stroke-width:2" />']
181 """
182 n = len(x1)
183
184 if n > max_n:
185 indices = np.linspace(0, n - 1, max_n, dtype="int")
186 else:
187 indices = range(n)
188
189 lines = [
190 ' <line x1="%d" y1="%d" x2="%d" y2="%d" />' % (x1[i], y1[i], x2[i], y2[i])
191 for i in indices
192 ]
193
194 lines[0] = lines[0].replace(" /", ' style="stroke-width:2" /')
195 lines[-1] = lines[-1].replace(" /", ' style="stroke-width:2" /')
196 return lines
197
198
199def 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