Plotly: How to change the colorscheme of a plotly express scatterplot?

前端 未结 2 2078
攒了一身酷
攒了一身酷 2021-02-15 16:52

I am trying to work with plotly, specifically ploty express, to build a few visualizations.

One of the things I am building is a scatterplot

I have some code bel

2条回答
  •  时光说笑
    2021-02-15 17:20

    You can use a method called color_discrete_map, which is a dict of k,v pairs where the k is the value for the color and v is the colorscheme. For example:

    fig = px.scatter(df, x='sepal_length', y='sepal_width',
                  color='species', color_discrete_map={'setosa': 'lightcyan', 
                                                       'versicolor': 'royalblue', 'virginica': 'darkblue'})
    

提交回复
热议问题