如何设置绘图图表在R中具有透明背景? [英] How to set plotly chart to have a transparent background in R?
本文介绍了如何设置绘图图表在R中具有透明背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
到目前为止,这就是我所拥有的:
Here's what I have, so far:
f1 <- list(
family = "Arial, sans-serif",
size = 25,
color = "white"
)
f2 <- list(
family = "Old Standard TT, serif",
size = 14,
color = "black"
)
a <- list(
title = "SALES PER SONG",
titlefont = f1,
showgrid = FALSE,
showticklabels = TRUE,
showline=TRUE,
tickangle = 45,
tickfont = f2
)
salesplot <-plot_ly(producersales, type="scatter", x=Producer, y=SalesPerSong, color=SongRange, colors=cols, mode="markers", size=SalesPerSong) %>%
layout(xaxis = a, yaxis = a)
我尝试在layout()
中的x和y轴信息之后添加paper_bgcolor=#00000000, plot_bgcolor=#00000000
,但是当我运行命令时,我得到了加号.我不知道该怎么办,因此不胜感激.谢谢!
I tried adding paper_bgcolor=#00000000, plot_bgcolor=#00000000
after the x and y axis information within layout()
, but when I run the command, I get the plus sign. I don't know what to do, so any help is appreciated. Thanks!
推荐答案
只需尝试:
salesplot <-plot_ly(producersales, type="scatter", x=Producer, y=SalesPerSong, color=SongRange, colors=cols, mode="markers", size=SalesPerSong) %>%
layout(xaxis = a, yaxis = a) %>%
layout(plot_bgcolor='rgb(254, 247, 234)') %>%
layout(paper_bgcolor='rgb(254, 247, 234)') #will also accept paper_bgcolor='black' or paper_bgcolor='transparent'
您可以更改rgb编号以适合您的需求.
You can change the rgb numbers to fit your needs.
这篇关于如何设置绘图图表在R中具有透明背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文