Skip to content

Commit 39ef1a6

Browse files
author
Peter Combs
committed
Allow automatic splitting by prefix
1 parent 1e9fc68 commit 39ef1a6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

PlotUtils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def svg_heatmap(data, filename, row_labels=None, box_size=4,
187187
max_width=np.inf,
188188
spacers=None,
189189
cmap_by_prefix=None,
190+
split_columns=False,
190191
vspacer=30,
191192
hatch_nan=True, hatch_size=20,
192193
first_col='', last_col=''):
@@ -224,7 +225,14 @@ def svg_heatmap(data, filename, row_labels=None, box_size=4,
224225
import svgwrite as svg
225226
import pandas as pd
226227

227-
if not isinstance(data, tuple):
228+
if split_columns and isinstance(data, pd.DataFrame):
229+
from Utils import sel_startswith
230+
colnames = list(sorted(
231+
{col.split(col_sep)[0] for col in data.columns}))
232+
data = tuple(
233+
data.select(**sel_startswith(colname)) for colname in colnames
234+
)
235+
elif not isinstance(data, tuple):
228236
data = (data,)
229237

230238
rows, cols = np.shape(data[0])

0 commit comments

Comments
 (0)