numpy - Create a heatmap using python -
i've simple csv in-fact a matrix
row/data, field_1, field_2, field_3 row_1, 223, 231, 5454 row_2, 4545, 4343, 23423 row_3, 3433, 325454, 34343 i generate heatmap in python axis labels being field names , rows names.
what recommended library use task?
we can use seaborn.heatmap method:
in [28]: import seaborn sns in [29]: df out[29]: row/data field_1 field_2 field_3 0 row_1 223 231 5454 1 row_2 4545 4343 23423 2 row_3 3433 325454 34343 in [30]: sns.heatmap(df.set_index('row/data'), annot=true, fmt='g') out[30]: <matplotlib.axes._subplots.axessubplot @ 0xc839358> yields:
or transposed:
in [32]: sns.heatmap(df.set_index('row/data').t, annot=true, fmt='g') out[32]: <matplotlib.axes._subplots.axessubplot @ 0xc341470> first check pandas visualization online docs - whether can cover needs.
seabornmodule pretty useful when working pandas data sets - check seaborn gallery - has couple of methods, not implemented in pandasanother greate visualization module bokeh, when need produce html reports.
and last not least - plot.ly - great online visualization tool.


Comments
Post a Comment