1

I am a newbie to Dash Framework and Plotly. I am trying to plot a bar chart. I want the x-axis to display only integral values . Here's the code of the dash core component:-x-axis

 dcc.Graph(id='bar-chart1', figure=px.bar(data_frame=df,
                                                     x='x', y='y',))

How do I display only integral values in x-axis like 17,18,19 ? Any help would be highly appreciated!

Anshuman Verma
  • 105
  • 1
  • 1
  • 8
  • Hi, you can try `fig.update_xaxes(type='category')`. – hoa tran May 05 '22 at 07:14
  • Hey hoa! What is fig here? I read the documentation of plotly but I couldn't figure out how to do it in Dash. Thank you very much for your comment! – Anshuman Verma May 05 '22 at 09:13
  • 1
    Maybe you can do something like that: `fig = px.bar(data_frame=df,x='x',y='y') fig.update_xaxes(type='category')` and then change `dcc.Graph to: dcc.Graph(id='bar-chart1', figure=fig))` – hoa tran May 05 '22 at 09:17

0 Answers0