Forum Discussion
R Visual with transparent background
Is it possible to create an R-Visual with a transparent background i.e. so that you can see an image added to the page background behing the plot the R-Visual generates?
Specifically I'm using ggplot2 and setting the fill of both plot.background andpanel.background to "transparent", but there still seems to be a white background between this and the background I can control through the PBI format options.
I don't know whether this will work with ggplot2 but in a visual I made based on the fmsb package I was able to work around this issue by using the par() function before the plotting was called:
# generic par function for graphical elements, call before the plotting
par(bg="transparent")
# this is wear the plotting of the visual actually happens radarchart(data)
20 Replies
- arvidbNew Member
I don't know whether this will work with ggplot2 but in a visual I made based on the fmsb package I was able to work around this issue by using the par() function before the plotting was called:
# generic par function for graphical elements, call before the plotting
par(bg="transparent")
# this is wear the plotting of the visual actually happens radarchart(data) - ankitpatiraCommunity Champion
- ross27Advocate II
Thanks Ankit. I do have that option set, but it just produces the result Herbert describes below.
- v-haibl-msftMicrosoft Employee
There is no option in Format pane to make the R visual background to be transparent. Only small part (around the R visual) can be transparent as below.
But we should be able to set bg="transparent" to make it to be transparent like below. Could you please share your R scripts written in the R script editor? Please also take a look at this link to see if it helps.
Best Regards,
Herbert
- ross27Advocate II
Thanks Herbert. This is the final part of my script:
g <- g + theme_void() + theme( axis.text.x = element_text(angle = 45,size=11,vjust=0.9), legend.position="none", plot.background = element_rect(fill="transparent", color=NA), panel.background = element_rect(fill="transparent", color=NA) ) par(bg="transparent") gBut as you can see I still have a white background:
- v-haibl-msftMicrosoft Employee
How about the result if update the script as below? If problem still persists, could you please share your .pbix file?
panel.background = element_rect(fill = "transparent",colour = NA), panel.grid.minor = element_blank(), panel.grid.major = element_blank(), plot.background = element_rect(fill = "transparent",colour = NA))
panel.background = theme_rect(fill = "transparent",colour = NA), panel.grid.minor = theme_blank(), panel.grid.major = theme_blank(), plot.background = theme_rect(fill = "transparent",colour = NA)
Best Regards,
Herbert
- PythonChanNew Member
Hi
Do you solve the problem?
I have the same issue,too.
If you have already solved the problem, could you send me the method by email, [email protected] ,please.
Thank you so much
- PythonChanNew Member
Hi
Do you solve the problem?
I have the same issue,too.
If you have already solved the problem, could you send me the method by email, [email protected] ,please.
Thank you so much
I'm sorry
just try again
- PythonChanNew Member
Hi
Do you solve the problem?
I have the same issue,too.
If you have already solved the problem, could you send me the method by email, [email protected] ,please.
Thank you so much
I'm sorry
just try again
- jfalltFrequent Visitor
I know this is an old thread but set the fill and the color of the element_rect layer equal to the background color
i.e. plot.background = element_rect(fill = "black", color = "black")Example Below: - Pierrick78Frequent Visitor
Any News on this issue in 2024 ??