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

Function svg_2d

dask/array/svg.py:49–78  ·  view source on GitHub ↗
(chunks, offset=(0, 0), skew=(0, 0), size=200, sizes=None)

Source from the content-addressed store, hash-verified

47
48
49def svg_2d(chunks, offset=(0, 0), skew=(0, 0), size=200, sizes=None):
50 shape = tuple(map(sum, chunks))
51 sizes = sizes or draw_sizes(shape, size=size)
52 y, x = grid_points(chunks, sizes)
53
54 lines, (min_x, max_x, min_y, max_y) = svg_grid(
55 x, y, offset=offset, skew=skew, size=size
56 )
57
58 header = (
59 '<svg width="%d" height="%d" style="stroke:rgb(0,0,0);stroke-width:1" >\n'
60 % (max_x + 50, max_y + 50)
61 )
62 footer = "\n</svg>"
63
64 if shape[0] >= 100:
65 rotate = -90
66 else:
67 rotate = 0
68
69 text = [
70 "",
71 " <!-- Text -->",
72 ' <text x="%f" y="%f" %s >%d</text>'
73 % (max_x / 2, max_y + 20, text_style, shape[1]),
74 ' <text x="%f" y="%f" %s transform="rotate(%d,%f,%f)">%d</text>'
75 % (max_x + 20, max_y / 2, text_style, rotate, max_x + 20, max_y / 2, shape[0]),
76 ]
77
78 return header + "\n".join(lines + text) + footer
79
80
81def svg_3d(chunks, size=200, sizes=None, offset=(0, 0)):

Callers 2

svgFunction · 0.85
svg_1dFunction · 0.85

Calls 4

draw_sizesFunction · 0.85
grid_pointsFunction · 0.85
svg_gridFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected