R Plotly Area Plot

Hello,
I am attempting to create a filled area plot using the code copied from here Filled Area Plots | R | Plotly

My chart looks like this:

The data looks like this:

f.ribbonData
# A tibble: 12 x 5
# Groups:   period [12]
   period periodName  minUI maxUI  midUI
   <chr>  <fct>       <dbl> <dbl>  <dbl>
 1 M01    January    0.033  0.08  0.0565
 2 M02    February   0.031  0.079 0.055 
 3 M03    March      0.0280 0.075 0.0515
 4 M04    April      0.026  0.071 0.0485
 5 M05    May        0.025  0.07  0.0475
 6 M06    June       0.0290 0.073 0.051 
 7 M07    July       0.0280 0.068 0.048 
 8 M08    August     0.0280 0.064 0.046 
 9 M09    September  0.027  0.062 0.0445
10 M10    October    0.027  0.062 0.0445
11 M11    November   0.027  0.06  0.0435
12 M12    December   0.027  0.059 0.043

I have defined periodName as a factor in month-order:
f.ribbonData$periodName <- factor(f.ribbonData$periodName,
levels = c(“January”, “February”, “March”,“April”, “May”, “June”,
“July”, “August”, “September”, “October”, “November”, “December”))

Finally, this is the code I used:

fig <- plot_ly(f.ribbonData, x = ~periodName, y = ~maxUI, type = 'scatter', mode = 'lines+markers',
               line = list(color = 'rgba(0,100,80,1)'),
               showlegend = FALSE, name = 'Max UI')
fig <- fig %>% add_trace(y = ~minUI, type = 'scatter', mode = 'lines+markers',
                         fill = 'tonexty', fillcolor='rgba(0,100,80,0.2)', line = list(color = 'rgba(0,100,80,1)'),
                         showlegend = FALSE, name = 'Min UI')
fig <- fig %>% layout(title = "Unemployment Rate",
                      paper_bgcolor='rgb(255,255,255)', plot_bgcolor='rgb(229,229,229)',
                      xaxis = list(title = "Months",
                                   gridcolor = 'rgb(255,255,255)',
                                   showgrid = TRUE,
                                   showline = FALSE,
                                   showticklabels = TRUE,
                                   tickcolor = 'rgb(127,127,127)',
                                   ticks = 'outside',
                                   zeroline = FALSE),
                      yaxis = list(title = "Unemployment Rate",
                                   gridcolor = 'rgb(255,255,255)',
                                   showgrid = TRUE,
                                   showline = FALSE,
                                   showticklabels = TRUE,
                                   tickcolor = 'rgb(127,127,127)',
                                   ticks = 'outside',
                                   zeroline = FALSE))

I cannot figure out why my chart does not look anything like the example.
Would appreciate any suggestions about how to make this work.

I used R version 4.0.3 (2020-10-10) and plotly version plotly_4.9.2.2

TIA
AB

Looks good to me:

library(plotly)

f.ribbonData <- structure(list(period = c("M01", "M02", "M03", "M04", "M05", 
"M06", "M07", "M08", "M09", "M10", "M11", "M12"), periodName = c("January", 
"February", "March", "April", "May", "June", "July", "August", 
"September", "October", "November", "December"), minUI = c("0.033", 
"0.031", "0.028", "0.026", "0.025", "0.029", "0.028", "0.028", 
"0.027", "0.027", "0.027", "0.027"), maxUI = c("0.08", "0.079", 
"0.075", "0.071", "0.07", "0.073", "0.068", "0.064", "0.062", 
"0.062", "0.06", "0.059"), midUI = c("0.0565", "0.055", "0.0515", 
"0.0485", "0.0475", "0.051", "0.048", "0.046", "0.0445", "0.0445", 
"0.0435", "0.043")), class = "data.frame", row.names = c(NA, -12L))

f.ribbonData$periodName <- factor(f.ribbonData$periodName,
 levels = c("January", "February", "March","April", "May", "June",
 "July", "August", "September", "October", "November", "December"))


fig <- plot_ly(f.ribbonData, x = ~periodName, y = ~maxUI, type = 'scatter', mode = 'lines+markers',
               line = list(color = 'rgba(0,100,80,1)'),
               showlegend = FALSE, name = 'Max UI')
fig <- fig %>% add_trace(y = ~minUI, type = 'scatter', mode = 'lines+markers',
                         fill = 'tonexty', fillcolor='rgba(0,100,80,0.2)', line = list(color = 'rgba(0,100,80,1)'),
                         showlegend = FALSE, name = 'Min UI')
fig <- fig %>% layout(title = "Unemployment Rate",
                      paper_bgcolor='rgb(255,255,255)', plot_bgcolor='rgb(229,229,229)',
                      xaxis = list(title = "Months",
                                   gridcolor = 'rgb(255,255,255)',
                                   showgrid = TRUE,
                                   showline = FALSE,
                                   showticklabels = TRUE,
                                   tickcolor = 'rgb(127,127,127)',
                                   ticks = 'outside',
                                   zeroline = FALSE),
                      yaxis = list(title = "Unemployment Rate",
                                   gridcolor = 'rgb(255,255,255)',
                                   showgrid = TRUE,
                                   showline = FALSE,
                                   showticklabels = TRUE,
                                   tickcolor = 'rgb(127,127,127)',
                                   ticks = 'outside',
                                   zeroline = FALSE))
fig

Result:

image

Thanks for the tip @ismirsehregal
I was able to produce the desired chart by converting the tibble to a data.frame with this command:
f.ribbonDataDF <- as.data.frame(f.ribbonData)

One question I have is how to control the colors of bottom lines and makers. In the image, the color of the line is green and the makers are orange, despite the color attribute of the “minUI” line is the same as the "maxUI line (line = list(color = ‘rgba(0,100,80,1)’)

I’ll keep working on this. I would appreciate any suggestions about how to resolve this.
Thanks again,
AB

Just provide the color argument on trace level (or add marker = list(color = 'rgba(0,100,80,1)')

library(plotly)

f.ribbonData <- structure(list(period = c("M01", "M02", "M03", "M04", "M05", 
                                          "M06", "M07", "M08", "M09", "M10", "M11", "M12"), periodName = c("January", 
                                                                                                           "February", "March", "April", "May", "June", "July", "August", 
                                                                                                           "September", "October", "November", "December"), minUI = c("0.033", 
                                                                                                                                                                      "0.031", "0.028", "0.026", "0.025", "0.029", "0.028", "0.028", 
                                                                                                                                                                      "0.027", "0.027", "0.027", "0.027"), maxUI = c("0.08", "0.079", 
                                                                                                                                                                                                                     "0.075", "0.071", "0.07", "0.073", "0.068", "0.064", "0.062", 
                                                                                                                                                                                                                     "0.062", "0.06", "0.059"), midUI = c("0.0565", "0.055", "0.0515", 
                                                                                                                                                                                                                                                          "0.0485", "0.0475", "0.051", "0.048", "0.046", "0.0445", "0.0445", 
                                                                                                                                                                                                                                                          "0.0435", "0.043")), class = "data.frame", row.names = c(NA, -12L))

f.ribbonData$periodName <- factor(f.ribbonData$periodName,
                                  levels = c("January", "February", "March","April", "May", "June",
                                             "July", "August", "September", "October", "November", "December"))


fig <- plot_ly(f.ribbonData, x = ~periodName, y = ~maxUI, type = 'scatter', mode = 'lines+markers',
               color = 'rgba(0,100,80,1)',
               showlegend = FALSE, name = 'Max UI')
fig <- fig %>% add_trace(y = ~minUI, type = 'scatter', mode = 'lines+markers',
                         fill = 'tonexty', fillcolor='rgba(0,100,80,0.2)', color = 'rgba(0,100,80,1)',
                         showlegend = FALSE, name = 'Min UI')
fig <- fig %>% layout(title = "Unemployment Rate",
                      paper_bgcolor='rgb(255,255,255)', plot_bgcolor='rgb(229,229,229)',
                      xaxis = list(title = "Months",
                                   gridcolor = 'rgb(255,255,255)',
                                   showgrid = TRUE,
                                   showline = FALSE,
                                   showticklabels = TRUE,
                                   tickcolor = 'rgb(127,127,127)',
                                   ticks = 'outside',
                                   zeroline = FALSE),
                      yaxis = list(title = "Unemployment Rate",
                                   gridcolor = 'rgb(255,255,255)',
                                   showgrid = TRUE,
                                   showline = FALSE,
                                   showticklabels = TRUE,
                                   tickcolor = 'rgb(127,127,127)',
                                   ticks = 'outside',
                                   zeroline = FALSE))
fig