How to change x axes labels in plot_ly?

I am trying to show 2 lines on a chart using the plotly library, and plot_ly() function in R.
The 2 lines represent cumulated counts of transactions per day during 2 consecutive years, so it would show how the current year performed compared to last year. On the x axis I only want to show the month and the day, not the year, because the month and day would be matching for both lines, but the year would be different.
I cannot figure out how to change the x axis labels to show different values than the x axis values based on what the chart shows.
I have exported my data frame with dput(), and here is the simplified example of what I try to do. Currently the x axis shows a lot of values overlapping on each other, and those values are actually from the "FiscalYear_Days" column, not the "Month-Day" column, so it looks like this line where I set the "ticktext" is ignored:

ticktext = chart_data$`Month-Day`[seq(1, length(chart_data$`Month-Day`), 20)],

here is my complete example:

chart_data = structure(list(`Month-Day` = c("05-01", "05-02", "05-03", "05-04", 
                               "05-06", "05-07", "05-08", "05-09", "05-10", "05-11", "05-12", 
                               "05-14", "05-15", "05-16", "05-17", "05-21", "05-22", "05-23", 
                               "05-24", "05-25", "05-27", "05-28", "05-29", "05-30", "05-31", 
                               "06-01", "06-03", "06-04", "06-05", "06-06", "06-08", "06-10", 
                               "06-11", "06-12", "06-13", "06-15", "06-16", "06-17", "06-19", 
                               "06-20", "06-21", "06-22", "06-25", "06-26", "06-28", "07-01", 
                               "07-02", "07-03", "07-04", "07-05", "07-07", "07-08", "07-09", 
                               "07-10", "07-11", "07-12", "07-13", "07-14", "07-15", "07-16", 
                               "07-18", "07-19", "07-20", "07-23", "07-24", "07-25", "07-26", 
                               "07-27", "07-28", "07-29", "07-30", "07-31", "08-01", "08-02", 
                               "08-03", "08-05", "08-06", "08-07", "08-08", "08-09", "08-10", 
                               "08-12", "08-13", "08-14", "08-15", "08-16", "08-17", "08-18", 
                               "08-20", "08-21", "08-22", "08-23", "08-24", "08-26", "08-27", 
                               "08-28", "08-29", "08-30", "08-31", "09-04", "09-05", "09-06", 
                               "09-07", "09-09", "09-10", "09-11", "09-12", "09-13", "09-14", 
                               "09-15", "09-17", "09-19", "09-21", "09-23", "09-24", "09-25", 
                               "09-26", "09-27", "09-28", "10-01", "10-02", "10-03", "10-04", 
                               "10-05", "10-09", "10-10", "10-11", "10-12", "10-13", "10-14", 
                               "10-15", "10-16", "10-18", "10-22", "10-23", "10-24", "10-26", 
                               "10-28", "10-29", "10-30", "10-31", "11-01", "11-02", "11-05", 
                               "11-06", "11-07", "11-08", "11-09", "11-12", "11-14", "11-16", 
                               "11-17", "11-20", "11-21", "11-22", "11-26", "11-28", "11-30", 
                               "12-02", "12-03", "12-04", "12-05", "12-06", "12-07", "12-08", 
                               "12-10", "12-12", "12-13", "12-14", "12-18", "12-19", "12-20", 
                               "12-21", "12-24", "12-27", "12-28", "12-29", "12-30", "12-31", 
                               "01-02", "01-03", "01-04", "01-07", "01-09", "01-11", "01-15", 
                               "01-18", "01-22", "01-29", "01-30", "01-31", "02-01", "02-05", 
                               "02-06", "02-07", "02-08", "02-12", "02-13", "02-19", "02-20", 
                               "02-21", "02-22", "02-24", "02-25", "02-26", "02-27", "02-28", 
                               "03-01", "03-02", "03-03", "03-04", "03-05", "03-06", "03-07", 
                               "03-08", "03-10", "03-12", "03-13", "03-14", "03-18", "03-19", 
                               "03-20", "03-21", "03-25", "03-27", "03-28", "03-30", "03-31", 
                               "04-01", "04-02", "04-03", "04-04", "04-06", "04-07", "04-08", 
                               "04-09", "04-11", "04-12", "04-13", "04-16", "04-18", "04-23", 
                               "04-24", "04-25", "04-26", "04-27", "04-29", "04-30", "05-01", 
                               "05-02", "05-03", "05-06", "05-07", "05-08", "05-09", "05-10", 
                               "05-12", "05-14", "05-15", "05-16", "05-17", "05-21", "05-22", 
                               "05-23", "05-24", "05-28", "05-30", "05-31", "06-03", "06-04", 
                               "06-05", "06-06", "06-08", "06-10", "06-11", "06-12", "06-17", 
                               "06-20", "06-21", "06-25", "06-26", "06-28"), FiscalYear_Days = c(0L, 
                                                                                                 1L, 2L, 3L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 13L, 14L, 15L, 16L, 
                                                                                                 20L, 21L, 22L, 23L, 24L, 26L, 27L, 28L, 29L, 30L, 31L, 33L, 34L, 
                                                                                                 35L, 36L, 38L, 40L, 41L, 42L, 43L, 45L, 46L, 47L, 49L, 50L, 51L, 
                                                                                                 52L, 55L, 56L, 58L, 61L, 62L, 63L, 64L, 65L, 67L, 68L, 69L, 70L, 
                                                                                                 71L, 72L, 73L, 74L, 75L, 76L, 78L, 79L, 80L, 83L, 84L, 85L, 86L, 
                                                                                                 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 96L, 97L, 98L, 99L, 100L, 
                                                                                                 101L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 111L, 112L, 113L, 
                                                                                                 114L, 115L, 117L, 118L, 119L, 120L, 121L, 122L, 126L, 127L, 128L, 
                                                                                                 129L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 139L, 141L, 143L, 
                                                                                                 145L, 146L, 147L, 148L, 149L, 150L, 153L, 154L, 155L, 156L, 157L, 
                                                                                                 161L, 162L, 163L, 164L, 165L, 166L, 167L, 168L, 170L, 174L, 175L, 
                                                                                                 176L, 178L, 180L, 181L, 182L, 183L, 184L, 185L, 188L, 189L, 190L, 
                                                                                                 191L, 192L, 195L, 197L, 199L, 200L, 203L, 204L, 205L, 209L, 211L, 
                                                                                                 213L, 215L, 216L, 217L, 218L, 219L, 220L, 221L, 223L, 225L, 226L, 
                                                                                                 227L, 231L, 232L, 233L, 234L, 237L, 240L, 241L, 242L, 243L, 244L, 
                                                                                                 246L, 247L, 248L, 251L, 253L, 255L, 259L, 262L, 266L, 273L, 274L, 
                                                                                                 275L, 276L, 280L, 281L, 282L, 283L, 287L, 288L, 294L, 295L, 296L, 
                                                                                                 297L, 299L, 300L, 301L, 302L, 303L, 304L, 305L, 306L, 307L, 308L, 
                                                                                                 309L, 310L, 311L, 313L, 315L, 316L, 317L, 321L, 322L, 323L, 324L, 
                                                                                                 328L, 330L, 331L, 333L, 334L, 335L, 336L, 337L, 338L, 340L, 341L, 
                                                                                                 342L, 343L, 345L, 346L, 347L, 350L, 352L, 357L, 358L, 359L, 360L, 
                                                                                                 361L, 363L, 364L, 365L, 366L, 367L, 370L, 371L, 372L, 373L, 374L, 
                                                                                                 376L, 378L, 379L, 380L, 381L, 385L, 386L, 387L, 388L, 392L, 394L, 
                                                                                                 395L, 398L, 399L, 400L, 401L, 403L, 405L, 406L, 407L, 412L, 415L, 
                                                                                                 416L, 420L, 421L, 423L), Last_Year = c(16, 17, 22, 25, 25, 25, 
                                                                                                                                        27, 28, 28, 33, 33, 34, 37, 37, 37, 37, 38, 41, 42, 43, 44, 44, 
                                                                                                                                        46, 47, 50, 56, 56, 60, 63, 65, 67, 68, 73, 77, 78, 80, 81, 81, 
                                                                                                                                        82, 84, 86, 89, 91, 94, 96, 96, 96, 101, 104, 108, 108, 108, 
                                                                                                                                        109, 110, 111, 114, 116, 117, 117, 121, 122, 125, 129, 134, 136, 
                                                                                                                                        137, 143, 144, 145, 147, 151, 152, 169, 176, 178, 179, 180, 188, 
                                                                                                                                        192, 195, 196, 197, 199, 200, 204, 206, 210, 211, 215, 217, 219, 
                                                                                                                                        220, 227, 230, 236, 240, 243, 245, 250, 263, 270, 273, 276, 277, 
                                                                                                                                        278, 281, 282, 285, 287, 288, 289, 291, 292, 293, 296, 298, 305, 
                                                                                                                                        307, 309, 317, 319, 321, 322, 323, 326, 329, 330, 331, 332, 333, 
                                                                                                                                        335, 336, 337, 339, 340, 342, 344, 345, 347, 349, 350, 354, 355, 
                                                                                                                                        359, 361, 365, 367, 369, 370, 371, 373, 374, 378, 379, 380, 381, 
                                                                                                                                        382, 383, 384, 395, 398, 400, 402, 406, 407, 419, 423, 425, 426, 
                                                                                                                                        430, 435, 437, 440, 444, 446, 450, 451, 452, 457, 460, 462, 463, 
                                                                                                                                        466, 468, 470, 471, 472, 474, 476, 478, 479, 487, 492, 493, 494, 
                                                                                                                                        495, 496, 497, 498, 499, 500, 501, 502, 503, 507, 510, 511, 521, 
                                                                                                                                        522, 524, 531, 533, 535, 536, 538, 539, 540, 541, 545, 546, 549, 
                                                                                                                                        550, 551, 556, 557, 560, 561, 562, 571, 577, 580, 582, 583, 584, 
                                                                                                                                        588, 589, 590, 593, 594, 595, 598, 600, 601, 604, 605, 606, 610, 
                                                                                                                                        612, 622, 626, 630, 631, 634, 637, 639, 641, 642, 644, 648, 650, 
                                                                                                                                        652, 653, 657, 658, 663, 667, 669, 671, 678, 682, 684, 689, 690, 
                                                                                                                                        695, 699, 703, 705, 706, 708, 710, 712, 713), This_Year = c(10, 
                                                                                                                                                                                                    14, 18, 18, 19, 22, 25, 27, 29, 29, 30, 32, 36, 38, 40, 41, 45, 
                                                                                                                                                                                                    46, 51, 51, 51, 55, 55, 57, 59, 59, 66, 70, 72, 77, 78, 83, 87, 
                                                                                                                                                                                                    91, 91, 91, 91, 93, 93, 94, 96, 96, 98, 100, 101, 103, 112, 114, 
                                                                                                                                                                                                    115, 117, 118, 120, 124, 128, 128, 130, 130, 131, 133, 137, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), row.names = c(NA, 
                                                                                                                                                                                                                                                                        -282L), class = "data.frame")

library(plotly)
plot_ly(chart_data, 
        x = ~`FiscalYear_Days`,
        y = ~Last_Year,
        name = 'Last_Year', 
        type = 'scatter',
        mode = 'lines',
        hoverinfo = "text",
        text = ~paste0("Month-Day: ", `Month-Day`, "\nRenewed: ", Last_Year)
) %>%
add_trace(y = ~This_Year, 
            name = 'This_Year',
            hoverinfo = "text",
            text = ~paste0("Renewed: ", This_Year)
) %>% 
layout(title=paste0("<b>Renewals - last year vs. this year</b>"),
         xaxis = list(title = "<b>Month - Day</b>",
                      showgrid = FALSE, 
                      tickangle = 270, 
                      dtick = 6, 
                      tickfont = list(size = 11),
                      ticktext = chart_data$`Month-Day`[seq(1, length(chart_data$`Month-Day`), 20)],
                      tickvals = chart_data$FiscalYear_Days,
                      tickmode = "array",
                      tickangle = 270
         ),
         yaxis = list(title = "<b>Renewals</b>",
                      ticklen = 8, 
                      tickcolor = "#000000",
                      tick0 = 0, 
                      tickfont = list(size = 11)),
         showlegend = TRUE,
         legend = list(x = 0, 
                       y = 1,
                       orientation = "h", 
                       traceorder = "normal"),
         margin = list(t = 25, b = 50, r = 10, l = 40)
) %>% 
config(displayModeBar = FALSE) %>%
layout(hovermode = 'compare')

Here is a screenshot with the result:

Thank you,
Steven

Plotly is tough. You are using tickmode="array" so tickvals and ticktext should have the same length.

tickvals = chart_data$FiscalYear_Days[seq(1, length(chart_data$`Month-Day`), 20)],

Thanks for your response.

I noticed that sometimes when I wanted to show less labels (on a more simple example), it was showing the label values from the array first, but when it finished all elements, it started showing other values from the "x = ~FiscalYear_Days".
So if I have too many values, is there ay way to show less labels? Or I need to remove records from my data? but then the lines wouldn't be that smooth, and a lot of days would be missing. At least now when you hover over the lines, it shows the values per every day.
Is there any other option I have to make the line charts? Someone showed me something with a the basic plot() function, but it doesn't look very nice. I wanted to place this in a Shiny dashboard, and I like how the plot_ly() has smooth lines, and has those features when you hover over.

Thanks,
Steven

Just replace some of the labels with "". It might be a good idea to construct the tickvals and ticktext vectors before you call plot_ly.

Thanks Simon, that was a good idea, I could have thought about that :slight_smile:
It works nice now, just had to add 1 line:

chart_data$`Month-Day`[setdiff(seq(1, length(chart_data$`Month-Day`)), seq(1, length(chart_data$`Month-Day`), 20))] = ""

So this is the modified complete code:

chart_data = structure(list(`Month-Day` = c("05-01", "05-02", "05-03", "05-04", 
                               "05-06", "05-07", "05-08", "05-09", "05-10", "05-11", "05-12", 
                               "05-14", "05-15", "05-16", "05-17", "05-21", "05-22", "05-23", 
                               "05-24", "05-25", "05-27", "05-28", "05-29", "05-30", "05-31", 
                               "06-01", "06-03", "06-04", "06-05", "06-06", "06-08", "06-10", 
                               "06-11", "06-12", "06-13", "06-15", "06-16", "06-17", "06-19", 
                               "06-20", "06-21", "06-22", "06-25", "06-26", "06-28", "07-01", 
                               "07-02", "07-03", "07-04", "07-05", "07-07", "07-08", "07-09", 
                               "07-10", "07-11", "07-12", "07-13", "07-14", "07-15", "07-16", 
                               "07-18", "07-19", "07-20", "07-23", "07-24", "07-25", "07-26", 
                               "07-27", "07-28", "07-29", "07-30", "07-31", "08-01", "08-02", 
                               "08-03", "08-05", "08-06", "08-07", "08-08", "08-09", "08-10", 
                               "08-12", "08-13", "08-14", "08-15", "08-16", "08-17", "08-18", 
                               "08-20", "08-21", "08-22", "08-23", "08-24", "08-26", "08-27", 
                               "08-28", "08-29", "08-30", "08-31", "09-04", "09-05", "09-06", 
                               "09-07", "09-09", "09-10", "09-11", "09-12", "09-13", "09-14", 
                               "09-15", "09-17", "09-19", "09-21", "09-23", "09-24", "09-25", 
                               "09-26", "09-27", "09-28", "10-01", "10-02", "10-03", "10-04", 
                               "10-05", "10-09", "10-10", "10-11", "10-12", "10-13", "10-14", 
                               "10-15", "10-16", "10-18", "10-22", "10-23", "10-24", "10-26", 
                               "10-28", "10-29", "10-30", "10-31", "11-01", "11-02", "11-05", 
                               "11-06", "11-07", "11-08", "11-09", "11-12", "11-14", "11-16", 
                               "11-17", "11-20", "11-21", "11-22", "11-26", "11-28", "11-30", 
                               "12-02", "12-03", "12-04", "12-05", "12-06", "12-07", "12-08", 
                               "12-10", "12-12", "12-13", "12-14", "12-18", "12-19", "12-20", 
                               "12-21", "12-24", "12-27", "12-28", "12-29", "12-30", "12-31", 
                               "01-02", "01-03", "01-04", "01-07", "01-09", "01-11", "01-15", 
                               "01-18", "01-22", "01-29", "01-30", "01-31", "02-01", "02-05", 
                               "02-06", "02-07", "02-08", "02-12", "02-13", "02-19", "02-20", 
                               "02-21", "02-22", "02-24", "02-25", "02-26", "02-27", "02-28", 
                               "03-01", "03-02", "03-03", "03-04", "03-05", "03-06", "03-07", 
                               "03-08", "03-10", "03-12", "03-13", "03-14", "03-18", "03-19", 
                               "03-20", "03-21", "03-25", "03-27", "03-28", "03-30", "03-31", 
                               "04-01", "04-02", "04-03", "04-04", "04-06", "04-07", "04-08", 
                               "04-09", "04-11", "04-12", "04-13", "04-16", "04-18", "04-23", 
                               "04-24", "04-25", "04-26", "04-27", "04-29", "04-30", "05-01", 
                               "05-02", "05-03", "05-06", "05-07", "05-08", "05-09", "05-10", 
                               "05-12", "05-14", "05-15", "05-16", "05-17", "05-21", "05-22", 
                               "05-23", "05-24", "05-28", "05-30", "05-31", "06-03", "06-04", 
                               "06-05", "06-06", "06-08", "06-10", "06-11", "06-12", "06-17", 
                               "06-20", "06-21", "06-25", "06-26", "06-28"), FiscalYear_Days = c(0L, 
                                                                                                 1L, 2L, 3L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 13L, 14L, 15L, 16L, 
                                                                                                 20L, 21L, 22L, 23L, 24L, 26L, 27L, 28L, 29L, 30L, 31L, 33L, 34L, 
                                                                                                 35L, 36L, 38L, 40L, 41L, 42L, 43L, 45L, 46L, 47L, 49L, 50L, 51L, 
                                                                                                 52L, 55L, 56L, 58L, 61L, 62L, 63L, 64L, 65L, 67L, 68L, 69L, 70L, 
                                                                                                 71L, 72L, 73L, 74L, 75L, 76L, 78L, 79L, 80L, 83L, 84L, 85L, 86L, 
                                                                                                 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 96L, 97L, 98L, 99L, 100L, 
                                                                                                 101L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 111L, 112L, 113L, 
                                                                                                 114L, 115L, 117L, 118L, 119L, 120L, 121L, 122L, 126L, 127L, 128L, 
                                                                                                 129L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 139L, 141L, 143L, 
                                                                                                 145L, 146L, 147L, 148L, 149L, 150L, 153L, 154L, 155L, 156L, 157L, 
                                                                                                 161L, 162L, 163L, 164L, 165L, 166L, 167L, 168L, 170L, 174L, 175L, 
                                                                                                 176L, 178L, 180L, 181L, 182L, 183L, 184L, 185L, 188L, 189L, 190L, 
                                                                                                 191L, 192L, 195L, 197L, 199L, 200L, 203L, 204L, 205L, 209L, 211L, 
                                                                                                 213L, 215L, 216L, 217L, 218L, 219L, 220L, 221L, 223L, 225L, 226L, 
                                                                                                 227L, 231L, 232L, 233L, 234L, 237L, 240L, 241L, 242L, 243L, 244L, 
                                                                                                 246L, 247L, 248L, 251L, 253L, 255L, 259L, 262L, 266L, 273L, 274L, 
                                                                                                 275L, 276L, 280L, 281L, 282L, 283L, 287L, 288L, 294L, 295L, 296L, 
                                                                                                 297L, 299L, 300L, 301L, 302L, 303L, 304L, 305L, 306L, 307L, 308L, 
                                                                                                 309L, 310L, 311L, 313L, 315L, 316L, 317L, 321L, 322L, 323L, 324L, 
                                                                                                 328L, 330L, 331L, 333L, 334L, 335L, 336L, 337L, 338L, 340L, 341L, 
                                                                                                 342L, 343L, 345L, 346L, 347L, 350L, 352L, 357L, 358L, 359L, 360L, 
                                                                                                 361L, 363L, 364L, 365L, 366L, 367L, 370L, 371L, 372L, 373L, 374L, 
                                                                                                 376L, 378L, 379L, 380L, 381L, 385L, 386L, 387L, 388L, 392L, 394L, 
                                                                                                 395L, 398L, 399L, 400L, 401L, 403L, 405L, 406L, 407L, 412L, 415L, 
                                                                                                 416L, 420L, 421L, 423L), Last_Year = c(16, 17, 22, 25, 25, 25, 
                                                                                                                                        27, 28, 28, 33, 33, 34, 37, 37, 37, 37, 38, 41, 42, 43, 44, 44, 
                                                                                                                                        46, 47, 50, 56, 56, 60, 63, 65, 67, 68, 73, 77, 78, 80, 81, 81, 
                                                                                                                                        82, 84, 86, 89, 91, 94, 96, 96, 96, 101, 104, 108, 108, 108, 
                                                                                                                                        109, 110, 111, 114, 116, 117, 117, 121, 122, 125, 129, 134, 136, 
                                                                                                                                        137, 143, 144, 145, 147, 151, 152, 169, 176, 178, 179, 180, 188, 
                                                                                                                                        192, 195, 196, 197, 199, 200, 204, 206, 210, 211, 215, 217, 219, 
                                                                                                                                        220, 227, 230, 236, 240, 243, 245, 250, 263, 270, 273, 276, 277, 
                                                                                                                                        278, 281, 282, 285, 287, 288, 289, 291, 292, 293, 296, 298, 305, 
                                                                                                                                        307, 309, 317, 319, 321, 322, 323, 326, 329, 330, 331, 332, 333, 
                                                                                                                                        335, 336, 337, 339, 340, 342, 344, 345, 347, 349, 350, 354, 355, 
                                                                                                                                        359, 361, 365, 367, 369, 370, 371, 373, 374, 378, 379, 380, 381, 
                                                                                                                                        382, 383, 384, 395, 398, 400, 402, 406, 407, 419, 423, 425, 426, 
                                                                                                                                        430, 435, 437, 440, 444, 446, 450, 451, 452, 457, 460, 462, 463, 
                                                                                                                                        466, 468, 470, 471, 472, 474, 476, 478, 479, 487, 492, 493, 494, 
                                                                                                                                        495, 496, 497, 498, 499, 500, 501, 502, 503, 507, 510, 511, 521, 
                                                                                                                                        522, 524, 531, 533, 535, 536, 538, 539, 540, 541, 545, 546, 549, 
                                                                                                                                        550, 551, 556, 557, 560, 561, 562, 571, 577, 580, 582, 583, 584, 
                                                                                                                                        588, 589, 590, 593, 594, 595, 598, 600, 601, 604, 605, 606, 610, 
                                                                                                                                        612, 622, 626, 630, 631, 634, 637, 639, 641, 642, 644, 648, 650, 
                                                                                                                                        652, 653, 657, 658, 663, 667, 669, 671, 678, 682, 684, 689, 690, 
                                                                                                                                        695, 699, 703, 705, 706, 708, 710, 712, 713), This_Year = c(10, 
                                                                                                                                                                                                    14, 18, 18, 19, 22, 25, 27, 29, 29, 30, 32, 36, 38, 40, 41, 45, 
                                                                                                                                                                                                    46, 51, 51, 51, 55, 55, 57, 59, 59, 66, 70, 72, 77, 78, 83, 87, 
                                                                                                                                                                                                    91, 91, 91, 91, 93, 93, 94, 96, 96, 98, 100, 101, 103, 112, 114, 
                                                                                                                                                                                                    115, 117, 118, 120, 124, 128, 128, 130, 130, 131, 133, 137, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                                                                                                                                                                                    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), row.names = c(NA, 
                                                                                                                                                                                                                                                                        -282L), class = "data.frame")

chart_data$`Month-Day`[setdiff(seq(1, length(chart_data$`Month-Day`)), seq(1, length(chart_data$`Month-Day`), 20))] = ""
library(plotly)
plot_ly(chart_data, 
        x = ~`FiscalYear_Days`,
        y = ~Last_Year,
        name = 'Last_Year', 
        type = 'scatter',
        mode = 'lines',
        hoverinfo = "text",
        text = ~paste0("Month-Day: ", `Month-Day`, "\nRenewed: ", Last_Year)
) %>%
add_trace(y = ~This_Year, 
            name = 'This_Year',
            hoverinfo = "text",
            text = ~paste0("Renewed: ", This_Year)
) %>% 
layout(title=paste0("<b>Renewals - last year vs. this year</b>"),
         xaxis = list(title = "<b>Month - Day</b>",
                      showgrid = FALSE, 
                      tickangle = 270, 
                      dtick = 6, 
                      tickfont = list(size = 11),
                      ticktext = chart_data$`Month-Day`,
                      tickvals = chart_data$FiscalYear_Days,
                      tickmode = "array",
                      tickangle = 270
         ),
         yaxis = list(title = "<b>Renewals</b>",
                      ticklen = 8, 
                      tickcolor = "#000000",
                      tick0 = 0, 
                      tickfont = list(size = 11)),
         showlegend = TRUE,
         legend = list(x = 0, 
                       y = 1,
                       orientation = "h", 
                       traceorder = "normal"),
         margin = list(t = 25, b = 50, r = 10, l = 40)
) %>% 
config(displayModeBar = FALSE) %>%
layout(hovermode = 'compare')

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.