如何解决R Plotly 添加图像水印
我想将图像/水印添加到双 y 轴图中,不知何故我的代码不起作用......这怎么可能?它没有错误,但没有添加图像
df <- data.frame(x = 1:50,y1 = c(20:5,6:10,9:3,4:20,19:15),y2 = c(100:115,200:204,50:44,66:62))
还有我的代码
plot_ly(df) %>%
add_lines(type = 'scatter',mode = "lines",name = "test",x = ~x,y = ~y1,line = list(color = '#999999'),hoverinfo = "text",text = ~paste(round(y1,1),x)) %>%
add_lines(type = 'scatter',yaxis = 'y2',y = ~y2,line = list(color = '#CC79A7'),text = ~paste(round(y2,x)) %>%
#layout
layout(title = "test",xaxis = list(titel = "Date",rangeslider = list(thickness = 0.05)),yaxis = list(side = 'left',title = 'test',showgrid = F,zeroline = F,type = "log",showline = T),images = list(source = "https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo.png",xref = "paper",yref = "paper",xanchor = "left",yanchor = "bottom",x= 4,y=4,sizex = 5,sizey = 5,opacity = 0.8),yaxis2 = list(side = 'right',overlaying = "y",showline = T))
解决方法
问题是您无法访问 Rstduio-logo.png。
- 创建一个 www 文件夹
- 在这个 www 文件夹中放一个 .png 假设我称之为 test.png
- 那么简单:
layout(images = list(source = "test.png"))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。