1

I'm creating a map of zipcodes in the US with a colorbar based on numerical values.

My data looks like

index   target1   color    geodata...
0       2000000   'yellow' XXXX

My code is:

import geopandas as gp
import pandas_bokeh
import bokeh
import matplotlib.pyplot as plt
from bokeh.plotting import figure, output_file, save
from bokeh.models import LinearColorMapper, CategoricalColorMapper

mapper = CategoricalColorMapper(palette=['#66ff00', '#32cd32', 'yellow', 'red'], 
                            factors=['#66ff00', '#32cd32', 'yellow', 'red'])
p = plot_df.plot_bokeh(simplify_shapes=10000, 
                     category="target1", 
                     color=mapper,
                     hovertool_columns=["target1"],
                     figsize=(900,600))

My map looks like this:

enter image description here

I want to change the colorbar and fillcolor of zips to a 4 color bar with set numbers

0-199 -> red, 
200-399 -> 'orange'
400-599 -> 'yellow'
600-799 -> 'green'

I've tried a few different methods (trying to change the color after mapping with p.patches(), passing mapper to plot_bokeh but none has worked.

Joe B
  • 912
  • 2
  • 15
  • 36
  • What library is `plot_bokeh` coming from? That is not a part of Bokeh itself. – bigreddot Jul 06 '21 at 18:58
  • @bigreddot the call to plot is called on a geopandas object so I presume it is a geopandas method. I've added my imports in to the question – Joe B Jul 06 '21 at 19:04
  • 1
    Fairly sure it's actually part of `pandas_bokeh`. You might have better luck asking the package author directly on their issue tracker https://github.com/PatrikHlobil/Pandas-Bokeh – bigreddot Jul 06 '21 at 19:33
  • will do! and will post solution here if I find it. – Joe B Jul 06 '21 at 20:14

0 Answers0