Hello, I am new to Dash app, and trying to run a simple scatter plot on the app. Somehow, there is no colorful dots showing up even setting up the specific dataframe column. Anybody has this kind issue? Many thanks!
Hey @AIMPED . Thank you for your reply. Good catch for x axis sorting. They are dtype(‘O’) and now sorted by datetime. But the chart is still black and white. Are there any hidden settings should be paid more attentions?
@AIMPED Thank you for the info. I didn’t realize plotly scatter have to be quantitative for both x and y axis, since it works well with Jupyter (y axis: categorical, x axis: quantitative). The solution you shared did work! However, I really want to keep the identity for yaxis and use the third column for color. Do you have any suggestions?
px.scatter() does also work with non- numeric values:
import pandas as pd
import plotly.express as px
import random
random.seed(42)
categories = 7
samples = 100
df = pd.DataFrame(
{
'x': [*range(samples)],
'y': [f'string_{i}' for i in range(samples)],
'color': [random.choice([f'cat_{i}' for i in range(categories)]) for _ in range(samples)]
}
)
fig = px.scatter(df,x='x', y='y', color='color')
fig.show()