Heatmap Does Not Show
I am trying to plot a simple heatmap from a dataframe that looks like this: row column content amount 0 x a c1 1 2 x b c3 3 4 x c
Solution 1:
Your x and y coordindates are swapped, should be:
p.rect(x="column", y="row", ...)
As for the other message, it is self-explanatory: As of Bokeh 1.2, ColorBar
can only be configured with continuous color mappers (e.g. LinearColorMapper
). You can either:
- compute colors yourself in Python code, and include a column of colors in
source
, or - re-cast your plot to use a
LinearColorMapper
(i.e. mapcontent
appropriately to some numerical scale)
Solution 2:
For your colorBar the solution is here, I quiet did not understand yet what happened to your source, I will dig a bit deeper another time. The colorBar expected a continuous mapper you gave it a categorical.
from bokeh.models import (CategoricalColorMapper, LinearColorMapper,
BasicTicker, PrintfTickFormatter, ColorBar, ColumnDataSource,
LinearColorMapper)
factors =df['content'].unique().tolist()
colors = all_palettes['Viridis'][max(len(factors), 3)]
mapper = LinearColorMapper(palette=colors)
Post a Comment for "Heatmap Does Not Show"