Plotly Bar Chart & Dates

Folks,

I’m having problems with how dates show up on the x axis of my bar plot. No matter how I format the dates in the dataframe, plotly keeps adding in between values. Below is my code.

#Create Last Week's Verificaiton Output Chart

#Verification Outputs
lw_count=df_lw.groupby(df_lw['TestDate']).count()

data = [go.Bar(
            x=lw_count.index,
            y=lw_count['TestID']
    )]

layout = dict(
    title= 'Pclean Output: Last Week',
    xaxis=dict(
        title='Date'),
    yaxis=dict(
        title='Verifications'))

fig=dict(data=data, layout=layout)

py.offline.iplot(fig)

Graph

I tried formatting the x axis with tickformat = ‘%a, %b %d’. But that will then produce the followinPreformatted textg image.

Graph2

Any and all help would be appreciated!

Cheers.

Hi @rjddatascience,

Try setting layout.xaxis.tickvals to your lw_count.index value. If supplied, this property specifies the exact location of each x-tick label.

Hope that helps!
-Jon

1 Like

Awesome dude! Thank you!

1 Like