You could use the sequence of numbers 1,2,3,...
until nrow(df)
as x variable, and supply your own tick marks. Example:
df = data.frame(date=c("1 Aug","1 Aug","2 Aug","3 Aug"),value=c(1,1.2,2,4))
plot_ly(df, x =1:nrow(df),
y =~value,type="scatter",
mode="lines") %>%
layout(xaxis=list(tickmode = 'array',
tickvals = 1:nrow(df),
ticktext = df$date,
range = c(0.5, nrow(df)+0.5)))
Result:
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.