I am using the rayshader package to render a 3D plot with plot_gg() function. How can I customize or reduce the height of the scale triangle legend bar of the plot since it will cover the plot partly when we increase the argument scale (e.g. scale = 300, etc.).
My code is as following:
gg_mai = ggplot(mai_sff)
geom_sf(aes(fill = songuoi_km), lwd=0)
scale_fill_viridis("Mật độ người/km2", direction = -1, option = "viridis")
ggtitle("Họ Mai")
theme_bw()
plot_gg(gg_mai, multicore = TRUE, raytrace = TRUE, width = 7, height = 4,
scale = 300, windowsize = c(1400, 866), zoom = 0.6, phi = 30, theta = 30)
Thank you so much!
CodePudding user response:
Well, you can define the key size in ggplot theme()
. Without a reproducible example, I only added some arbitrary numbers. You may want to try different numbers on your side, even change the legend position.
gg_mai = ggplot(mai_sff)
geom_sf(aes(fill = songuoi_km), lwd=0)
scale_fill_viridis("Mật độ người/km2", direction = -1, option = "viridis")
ggtitle("Họ Mai")
theme_bw()
theme(
legend.key.height = unit(2, "mm"),
legend.key.width = unit(1, "mm")
)
plot_gg(gg_mai, multicore = TRUE, raytrace = TRUE, width = 7, height = 4,
scale = 300, windowsize = c(1400, 866), zoom = 0.6, phi = 30, theta = 30)
CodePudding user response:
Thanks! I've tried. But it actually only customize the height and the width of the legend key with respect to ggplot() function in 2D. It still does not work for the height of the scale in 3D. Does it have something to do to specify in plot_gg()?It looks like this