How to use the branca.colormap.linear function in branca

To help you get started, we’ve selected a few branca examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-visualization / folium / tests / plugins / test_time_slider_choropleth.py View on Github external
styledata = {}

    for country in gdf.index:
        pdf = pd.DataFrame(
            {'color': np.random.normal(size=n_periods),
             'opacity': np.random.normal(size=n_periods)},
            index=dt_index)
        styledata[country] = pdf.cumsum()

    max_color, min_color = 0, 0

    for country, data in styledata.items():
        max_color = max(max_color, data['color'].max())
        min_color = min(max_color, data['color'].min())

    cmap = linear.PuRd_09.scale(min_color, max_color)

    # Define function to normalize column into range [0,1]
    def norm(col):
        return (col - col.min())/(col.max()-col.min())

    for country, data in styledata.items():
        data['color'] = data['color'].apply(cmap)
        data['opacity'] = norm(data['opacity'])

    styledict = {str(country): data.to_dict(orient='index') for
                 country, data in styledata.items()}

    m = folium.Map((0, 0), tiles='Stamen Watercolor', zoom_start=2)

    time_slider_choropleth = TimeSliderChoropleth(
        gdf.to_json(),
github python-visualization / branca / tests / test_colormap.py View on Github external
def test_linear_to_step():
    some_list = [30.6, 50, 51, 52, 53, 54, 55, 60, 70, 100]
    lc = cm.linear.YlOrRd_06
    lc.to_step(n=12)
    lc.to_step(index=[0, 2, 4, 6, 8, 10])
    lc.to_step(data=some_list, n=12)
    lc.to_step(data=some_list, n=12, method='linear')
    lc.to_step(data=some_list, n=12, method='log')
    lc.to_step(data=some_list, n=30, method='quantiles')
    lc.to_step(data=some_list, quantiles=[0, 0.3, 0.7, 1])
    lc.to_step(data=some_list, quantiles=[0, 0.3, 0.7, 1], round_method='int')
    lc.to_step(data=some_list, quantiles=[0, 0.3, 0.7, 1],
               round_method='log10')
github python-visualization / branca / tests / test_colormap.py View on Github external
def test_linear_object():
    cm.linear.OrRd_06._repr_html_()
    cm.linear.PuBu_06.to_step(12)
    cm.linear.YlGn_06.scale(3, 12)
    cm.linear._repr_html_()
github jupyter-widgets / ipyleaflet / ipyleaflet / leaflet.py View on Github external
def _default_colormap(self):
        return linear.OrRd_06