I have the following data:
myData <- data.frame(FISCAL_YEAR_WEEK = c(\'2016-09\',\'2016-09\',\'2016-09\',\'2016-09\',\'2016-09\',\'2016-10\',\'2016-10\',\
Until recently, the only way to sort a plot.ly categorical axis was to sort the data of the first categorical trace of the graph (ref: Etienne's answer on plot.ly community site).
That's changed, and you can achieve the categorical axis sort you desire by setting categoryorder in either of the following manners:
ax <- list(
type = "category",
categoryorder = "category ascending",
showgrid = TRUE,
showline = TRUE,
autorange = TRUE,
showticklabels = TRUE,
ticks = "outside",
tickangle = 0
)
Or:
ax <- list(
type = "category",
categoryorder = "array",
categoryarray = sort(unique(myData$FISCAL_YEAR_WEEK)),
showgrid = TRUE,
showline = TRUE,
autorange = TRUE,
showticklabels = TRUE,
ticks = "outside",
tickangle = 0
)
For more on plot.ly's categorical axis sort, see their reference doc.