Point color on deck_gl_chart ScatterplotLayer

Hey there

I’m having a hard time with deck gl chart, the examples work just fine but as soon as I try to do something slightly more complex I stumble into problems. The documentation is not a big help either. I understand that this is probably due to the fact that this is a wrapper around a js library.

Anyway, my extremely simple problem is, how do I set the color of the dots on a scatter plot based on the value of a column?

I tried several combinations including the getColorR/G/B property inside an encoding dictionary as described in the docs but with no luck. E.g.

      layers=[
          {
            "type": "ScatterplotLayer",
            "data": df,
            "encoding":{
              "getColor": "colorR"
            }
          }
      ],

Where colorR is an existing column on my df (tried with values from 0 to 1 and values from 0 to 255).

Can someone provide a working (even if simple) example?

Thank you in advance

Hi @Alexandre_Domingues ,

I also came across this issue. So far, here is the code I managed to get running to have multiples colors on my map :

layers=[  
        {
         'id': "scat-blue",
         'type': 'ScatterplotLayer',
         'data': data.iloc[:25],
         'opacity': 1,
         'getColor': [75,205,250],
         'pickable': True,
         'autoHighlight': True,
         'getRadius': 200,
         'radiusMinPixels': 5,
          },{
         'id': 'scat-red',
         'type': 'ScatterplotLayer',
         'data': data.iloc[25:50],
         'opacity': 1,
         'getColor': [255,94,87],
         'autoHighlight': True,
         'pickable': True,
         'getRadius': 200,
         'radiusMinPixels': 5,
         }
     ] 

I hope that helps :slight_smile:
Best,

1 Like

Thanks for your reply.
I was also able to add different colors to different data points by plotting them in separate layers, it should be possible to do it with a single layer.
I guess it will do for now :+1:

1 Like