mapbox/mapboxgl-jupyter

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

kevinlib opened this issue · 5 comments

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?

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

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.

@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 :)

@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.

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