I’m doing a Bokeh application in which I have an input table, some calculations are performed on it and it produces a new table. I’m trying to plot a heatmap of this new table, so I have to create a colorbar using the LinearColorMapper function, however I can’t use the min and max values from the calculated table (which is a ColumnDataSource), this is how the table is stored:
def val_portafolio_mostrar(): val_portafolio=datos_calcular() val_mapa=pd.DataFrame(val_portafolio.stack(), columns=['valoracion']).reset_index() datos_heatmap.data=dict(val_mapa)
The values which are going to be plotted on the heatmap are in the ‘valoracion’ column from datos_heatmap, this is the code I’m using for the LinearColorMapper
colors = ["#75968f", "#a5bab7", "#c9d9d3", "#e2e2e2", "#dfccce", "#ddb7b1", "#cc7878", "#933b41", "#550b1d"] mapper = LinearColorMapper(palette=colors, low=min(datos_heatmap.data['valoracion']), high=max(datos_heatmap.data['valoracion']))
however I’m getting the following error:
in mapper_fun mapper = LinearColorMapper(palette=colors, low=min(datos_heatmap.data['valoracion']), ValueError: min() arg is an empty sequence
I think it’s because in order to access a ColumnDataSource value, the function needs to have the “source” parameter, however the LinearColorMapper function does not have this parameter so it’s not possible to solve it this way. I also tried to store the max and min values in another ColumnDataSource but I get the same error because I’m not using a source rather just extracting the values as in “datos_heatmap.data[‘valoracion’]”
Thanks in advance!