mapbox / mapboxgl-jupyter

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

How to hide null/Nan values on a CircleViz ? #188

Open annesophie-cls opened 2 years ago

annesophie-cls commented 2 years ago

Null values are displayed with black circles on the map How can i hide them ?

code1

code2

akacarlyann commented 2 years ago

Neat viz!! How about dropping the nans from your data frame?

datadf.dropna(inplace=True)

The other thing you could do is alter the color stops so the default color is rgba(0,0,0,0) or directly supply a transparent color_default='rgba(0,0,0,0)' to CircleViz.

annesophie-cls commented 2 years ago

Thank you for your answer

dropna() is a solution I tried before, it works when there are other values than NaN is the dataframe, but when the dataframe is empty (had only NaN), the map is not displayed at all (blank page)

The color_default='rgba(0,0,0,0)' in CircleViz doesn't change anything

akacarlyann commented 2 years ago

In this particular case, it wouldn't be an empty dataframe though, would it? What about just dropping the entries where "ssh_karin" is null before creating the geojson layer?

Thanks for the reminder about the color default. I forgot that is for categorical color stops. It would be good to have the option to customize the color for missing data, though we didn't want to hide those points by default.