Reputation: 369
I am trying to represent some point data for a region in 3D using the Rayshader package. It plots everything correctly, except that the background is totally black. How to fix this? Below is my code:
base_map <- ggplot(data = df.shp, mapping = aes(x = long, y = lat, group = group)) +
geom_polygon(color = "#8a8a8a", fill = "#8a8a8a") +
coord_quickmap() +
theme_void()
growing_stock = base_map +
geom_point(data = temp1, aes(x=longitude, y=latitude, color=volume_per_ha, group=time),size=2) +
scale_colour_gradient(name = 'Average growing stock [m3/ha]',
limits=range(temp1$volume_per_ha),
low="#FCB9B2", high="#B23A48")
growing_stock
plot_gg(growing_stock, width=5, height=5, multicore = TRUE, scale = 300)
Here is how the plot looks like
Upvotes: 1
Views: 1272
Reputation: 126
I had the same issue. It's an OS problem.
Same code: -theme_void() + macOS = no black square -theme_void() + windows = black square around the plot
I think the first answer is the only solution for now. It blends a little better if you change the shadowcolor in plot_gg() to be the same as the lightcolor in renderhighquality().
Upvotes: 0
Reputation: 6769
You have several options to fix this. Removing theme_void
, or replacing it with one of other themes can change the background color, but will add some other ggplot2
components to the graph that you may not want. One easy way to fix the problem is just to explicitly change the background color using theme()
.
base_map <- ggplot(data = df.shp, mapping = aes(x = long, y = lat, group = group)) +
geom_polygon(color = "#8a8a8a", fill = "#8a8a8a") +
coord_quickmap() +
theme_void() +
theme(
plot.background = element_rect(
fill = "white",
colour = "white"
)
)
I changed background color to "white" in this example. You may want to change to another color.
Upvotes: 2