✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
📊 Dash 2.0 is Arriving. Register here.

Plotly Express with xaxis having Integers & Strings

I’m working with a data set that’s got mix of integers & strings on the x axis and plotly express is only graphing the integers.

The FrameSize column has the following data in it [‘70’, ‘128’, ‘1000’, ‘1400’, ‘1500’, ‘iMix’]. It seems that the Pandas dataframe is saving the intigers as floats so I’m changing them to strings with the following.

fs_df.loc[:, ‘FrameSize2’] = fs_df[‘FrameSize’].astype(int, errors=‘ignore’).astype(str)

However, when I graph this I’m still only getting the numerical values with no iMix column.

Hi @MrPaul, welcome to the forum! I think here you have to force the xaxis to have a ‘category’ type, as follows

import plotly.express as px
df = {'x':[1, 2, 3, 'a'], 'y':[5, 1, 3, 3]}
fig = px.bar(df, x='x', y='y')