Skip to content

plotly express do not displaying color-category name if function applied #2070

@OleksiiYeromenko

Description

@OleksiiYeromenko

When I set "color=" to column from my dataframe but applying any function to it - I got in fig. legend just 'color'.
Cant figure out how to set it manually if I need to set custom color, not just existing column from my dataset.

Screenshot_2

Example for reproduce:

df = pd.DataFrame({'x':[1,2,3,4,5,6,7],'y':[1,2,3,4,5,6,7],'color':[-100,0,1,1000,5000,3000,7000]})

fig = px.scatter(df, x='x', y='y'
                 ,size=df.groupby(by=['y','x'])['y'].transform('count')
                 #,color=df['color']
                 ,color=df['color'].apply(np.log)
                 ,color_continuous_scale=px.colors.sequential.Inferno
                 ,opacity=0.7
                )
fig.show()

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions