I am using Plotly R to produce the chart in the screen grab below:
When I save the chart using the “Download Plot as png” icon the annotations are below the image boundaries and much lower the x-axis label as desired:
How can I configure the image so that the displayed image and the downloaded image are identical?
Below is the relevant part of my code:
fig <- plot_ly(f.chartData, x = ~periodName, y = ~maxUI, type = 'scatter', mode = 'lines+markers',
line = list(color = 'rgba(0,0,255,1)'),
name = rngSTR, text = ~maxText, hoverinfo = 'text') %>%
config( toImageButtonOptions = list(format = "png", filename = total_tit,
width = 1450, height = 550))
fig <- fig %>% add_trace(y = ~minUI, type = 'scatter', mode = 'lines+markers',
fill = 'tonexty', fillcolor='rgba(173,216,230,0.4)', line = list(color = 'rgba(0,0,255,1)'),
marker = list(color = 'rgba(0,0,255,1)'),
showlegend = FALSE, name = rngSTR, text = ~minText, hoverinfo = 'text')
fig <- fig %>% add_trace(y = ~midUI, type = 'scatter', mode = 'lines+markers',
line = list(color = 'rgba(0,0,0,1)'),
marker = list(color = 'rgba(0,0,0,1)'),
name = midSTR, text = ~midText, hoverinfo = 'text')
fig <- fig %>% add_trace(y=~prevUI, type = 'scatter', mode = 'lines+markers',
line = list(color = 'rgba(165,42,42,1)'),
marker = list(color = 'rgba(165,42,42,1)'),
name = prevSTR, text = ~prevText, hoverinfo = 'text')
fig <- fig %>% add_trace(y=~curUI, type = 'scatter', mode = 'lines+markers',
line = list(color = 'rgba(255,0,0,1)'),
marker = list(color = 'rgba(255,0,0,1)'),
name = curSTR, text = ~curText, hoverinfo = 'text')
fig <- fig %>% layout(margin = list(l = 50, r = 50, t = 60, b = 105),
title = titleSTR,
paper_bgcolor='rgb(255,255,255)', plot_bgcolor='rgb(229,229,229)',
hoverlabel = "right",
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,
tickformat = "%",
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
annotations = list(text=captionSTR, xref = 'paper', x = 0,
yref = 'paper', y = -0.35,
align='left', showarrow=FALSE,
font=list(size=10)))
Thanks in advance
AB