Skip to content

Commit f6a04d5

Browse files
author
Peter Combs
committed
Add hatching as optional in SVG_heatmap
1 parent 78683c1 commit f6a04d5

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

PlotUtils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def svg_heatmap(data, filename, row_labels=None, box_size=4,
144144
draw_box=False, draw_name=False, data_names=None,
145145
max_width=np.inf,
146146
spacers=None,
147+
hatch_nan=True, hatch_size=20,
147148
first_col='', last_col=''):
148149
"""
149150
Draw heatmap as an SVG file stored in filename
@@ -200,9 +201,9 @@ def svg_heatmap(data, filename, row_labels=None, box_size=4,
200201
pat = dwg.pattern(id='hatch', insert=(0, 0), size=(25, 25),
201202
patternUnits='userSpaceOnUse')
202203
g = pat.add(dwg.g(style="fill:none; stroke:#B0B0B0; stroke-width:1"))
203-
g.add(dwg.path(('M0,0', 'l20,20')))
204-
g.add(dwg.path(('M10,0 l10,10'.split())))
205-
g.add(dwg.path(('M0,10 l10,10'.split())))
204+
g.add(dwg.path(('M0,0', 'l{hatch},{hatch}'.format(hatch=hatch_size))))
205+
g.add(dwg.path(('M{hatch2},0 l{hatch2},{hatch2}'.format(hatch2=hatch_size/2).split())))
206+
g.add(dwg.path(('M0,{hatch2} l{hatch2},{hatch2}'.format(hatch2=hatch_size/2).split())))
206207

207208
dwg.add(pat)
208209

@@ -302,7 +303,7 @@ def svg_heatmap(data, filename, row_labels=None, box_size=4,
302303
.format(*[int(255*x) for x in
303304
c_cmap(norm_data.ix[i, j])])))
304305
dwg.add(g)
305-
if hatch:
306+
if hatch_nan and hatch:
306307
g.add(dwg.rect((x_start + box_size*j,
307308
y_start + i*box_height),
308309
(box_size, box_height),

0 commit comments

Comments
 (0)