Bring Drag & Drop to Dash with Dashboard Engine. 💫 Learn how at our next webinar!

Plotly Express scatter plot not showing symbols correctly

Hi there,

I am trying to do a scatter plot with plotly_express and I want to assign different colors and symbols based on the columns of my DataFrame. The problem is that only around 4 symbols are used and I have more than 20 cathegories. The values in the column for different colors that I am referencing are strings with different organ names, e.g.: [“stomach”, “heart”, “liver”, “lungs”, …]. The column that I am referencing for the symbols contains strings with values like [“P001”, “P015”, “P009”, …]. I also tried passing a list of integer values depending on the organ name but it still did not work. Below I share the core I am using. Also I add a picture of how it looks for me.

fig = px.scatter(df_manifold, x=x_col, y=y_col, color=c_col, title=f"{title_prefix} of multi organ database",
    color_discrete_sequence=my_color_palette, category_orders=category_order, symbol="replicate")

df_manifold is a data frame with columns: [x_col, y_col, c_col, "replicate"]. c_col and replicate are the columbs for the color and symbol respectively.

Solution:
I solved it now by passing together symbol_map which is a dictionary mapping from the values of the column to symbol codes that Plotly can interpret. For a list of symbols look at the end of this page: https://plotly.com/python/marker-style/

I solved it now by passing together symbol_map which is a dictionary mapping from the values of the column to symbol codes that Plotly can interpret. For a list of symbols look at the end of this page: https://plotly.com/python/marker-style/