Plotly: How to plot dates on boxplot x-axis?

Viewed 794

I am trying to plot a box plot of a dataframe in plotly, dataframe is as follows:

input dataframe

I have tried the following:

data = [go.Box(y = Y.iloc[:,i].values) for i, j in enumerate(Y.columns)]
layout = go.Layout(title = 'box plot')
fig = go.Figure(data=data, layout=layout)
fig.show()

I have successfully plotted the desired boxplot,but am not able to plot dates in column headers on X axis of boxplot. Can someone help?

Output is as follows:

Output Image

2 Answers

To display the dates along the x-axis, you can assign a name for each box plot set to the corresponding date

data=[go.Box(y = Y.iloc[:,i].values, name = j) for i,j in enumerate(Y.columns)]
layout = go.Layout(title = 'box plot')
fig = go.Figure(data=data, layout=layout)
fig.show()

enter image description here

i am not sure nut I hope this simple trick might work. Firstly perform the transpose of the dataframe and then .reset_index()and then again transpose . This will convert the column headers into your first row and might help you to plot it

Related