2

I am using cufflink iplot. the default hover date info only include month and year. How to include day as well? like (Jan 24 2022, value) instead of (Jan 2022, value) by default? and there is not hovermode keyword. Thanks

import cufflinks as cf
from plotly.offline import iplot  #, init_notebook_mode

df.iplot(asFigure=True, xTitle='Date')

Derek O
  • 16,770
  • 4
  • 24
  • 43
roudan
  • 3,082
  • 5
  • 31
  • 72

1 Answers1

1

I tried a simple example and the day appears for me in the hovertemplate. Are the datetimes in your df of type datetime64[ns]?

import cufflinks as cf
import pandas as pd
from plotly.offline import iplot

df = pd.DataFrame({'date':['2022-01-01','2022-01-02'],'value':[1,2]})
df['date'] = pd.to_datetime(df['date'])
fig = df.iplot(asFigure=True, x='date', xTitle='Date')
fig.show()

enter image description here

Another thing you could try is modifying the hovertemplate itself. Something like the following (assuming that the x value is the datetime and the y value is the value):

fig.update_traces(hovertemplate='Date: %{x|%b %d, %Y} <br>Value: %{y}')

enter image description here

Derek O
  • 16,770
  • 4
  • 24
  • 43