'Show year only on the first axis tick or on change
I have a question regarding axis formatting of dates in R plotly.
I want to specify custom date tickformats on my x-axis as follows: '%a %e %b \n %Y' But I only want to show the year on the first xaxis tick. As it would be too weird to repeat it for each tick label.
I have the following small example:
dt <- data.frame(
x = as.Date(c('2013-02-04', '2013-04-05', '2013-06-06', '2013-08-07', '2013-10-02')),
y = c(1,4,5,6,2)
)
plot_ly(data = dt, x = ~x, y = ~y, type = 'scatter', mode = 'lines') %>%
layout(xaxis = list(tickformat = '%a %e %b \n %Y'))
Which is the exact same setup from this javascript example where it does work!
This post with python also seems to work. So I am not sure now what I am doing wrong in R? Or if this is a bug?
Edit: I would like to avoid using ggplotly and directly work with plotly as this provide greater control.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


