I have this list of lists. These data should be represented as 3 different heatmaps.
data_array = [[[1.0, 0.13790931989924432, -0.0919779252979285, 0.12174212725627881],
[0.13790931989924432, 1.0, -0.0005118143819841338, 0.03747498635619429],
[-0.0919779252979285, -0.0005118143819841338, 1.0, 0.06857971615041956],
[0.12174212725627881, 0.03747498635619429, 0.06857971615041956, 1.0]],
[[1.0, 0.3103448275862069, 0.08571428571428572, 0.11764705882352941],
[0.3103448275862069, 1.0, 0.16923076923076924, 0.10144927536231885],
[0.08571428571428572, 0.16923076923076924, 1.0, 0.013333333333333334],
[0.11764705882352941, 0.10144927536231885, 0.013333333333333334, 1.0]],
[[1.0, 0.10930636482092237, -0.047154899617311986, 0.13299499622264638],
[0.1093063648209226, 1.0, 0.014284516205891629, 0.0912683000085494],
[-0.0471548996173124, 0.014284516205891629, 1.0, 0.20172045383255874],
[0.13299499622264643, 0.09126830000854978, 0.20172045383255963, 1.0]]]
So I transformed the data in Xarray
data_xarray = xarray.DataArray(
data=data_array,
dims=['Metrics', 'Parameter', 'Parameter'],
coords={'Metrics': [1,2,3],
'Parameter': ['Size', 'Depth', 'Diet', 'Taxon']
}
)
Now I want to show the 3 heatmaps
fig = px.imshow(data_xarray, facet_col='Metrics', color_continuous_scale=multicolor_scale, zmax=1)
As you can see the heatmaps are correctly subdivided according to the βMetricsβ.
The problem is that I need to change βMetricsβ to a list of strings like βMetricsβ: [βaβ, βbβ, βc,β] instead of [1,2,3].
If I do that an error pops up
**TypeError** : %d format: a number is required, not numpy.str_
The error depends on px.imshow and not on xarray.Datarray. For some reason it only accepts integers.
Does anyone have a solution for this?