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

Plotly Express Bar Chart with set range hides data

I have a bar chart, and there is not always data for every day, so to make it look nice, I set range_x = a fixed range. However, when I do that, no data is displayed in the bar chart: image

But when you auto-scale the data is displayed, but not with the fixed range: image

I’m not sure if this is a bug or if I am just doing something wrong. It only happens when there is 1 item in the data frame.

    # data = {'date': ['2020-08-05', '2020-08-07'], 'count': [2, 1]}
    data = {'date': ['2020-08-05'], 'count': [2]}
    df = pd.DataFrame(data=data)
    fig = px.bar(df,  x='date', y='count', title='Users', range_x=['2020-08-03', '2020-08-10'])

    fig.update_layout(xaxis_title="Date", yaxis_title="Count", xaxis={'tickformat': '%b %d'})
    fig.update_xaxes(ticks="outside", tickson="boundaries", tickmode="linear")