mapbox / mapboxgl-jupyter

Use Mapbox GL JS to visualize data in a Python Jupyter notebook
MIT License
661 stars 136 forks source link

Support MapboxGL 'step' expression for color and height function types #169

Open kevinlib opened 4 years ago

kevinlib commented 4 years ago

When I create the Viz object and try to pass in a different color_function_type value (e.g. 'step'), the Viz display maintains the interpolate function even though the attribute in the Viz object has been changed.

Any ideas on why this is happening?

akacarlyann commented 4 years ago

Hi @kevinlib! Can you describe the 'step' color_function_type? In the docs, I only see support for 'interpolate' (the default) or 'match'.

kevinlib commented 4 years ago

I'd like to have discrete steps instead of having a continuous scale by interpolating. For reference: https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-step. I couldn't find in the docs the supported values.

akacarlyann commented 4 years ago

@kevinlib As a quick fix, I would suggest binning your source data and assigning a color_property that can be used with the 'match' color function. Let me know if that makes sense for your use case?

You might also want to take a look at PR #161 .

Longer term-- sounds like the issue here is you'd like support for the native MapboxGL step expression. Mind if I update the issue title to reflect that? Then someone can get started on a PR for this feature :)

akacarlyann commented 4 years ago

@kevinlib Also to strictly answer your original q: changing the color_function_type will only have an effect if it is changed to 'match' or (soon) 'identity' (when #161 gets merged in). Otherwise, it will default to 'interpolate'. Thanks for pointing out that we may need to provide some logic to validate other user input.

kevinlib commented 4 years ago

@akacarlyann, thanks for being so responsive. I'll try out binning beforehand with 'match' and yes feel free to change the issue title.