I am using the hist3D function from the plot3D package in R to create a 3D bar plot.
However, the top plane of the bars in the plot is rectangular, and I want it to be square.
Below is my reproducible code and data:
library(plot3D)
dd2 = structure(c(1, 3.07, 1.87, 4.6, 5.71, 0.68), dim = 2:3, dimnames = list(
c("正常", "异常"), c("<120/80", "120-139/80-89", "≥140/90"
)))
m2 <- matrix(1:length(dd2),
nrow = nrow(dd2))
colors <- c("#3d6ab4", "#deb44c", "#f47d1f", "#84c347", "#78cae5", "#66468c")
hist3D(z = dd2,
scale = FALSE,
expand = 0.3,
bty = "g",
theta = 15,
phi = 20,
d = 2,
r = 20,
border = 'white',
shade = 0.1,
ltheta = 40,
space = 0.9,
ticktype = "detailed",
zmin = 0,
zlim = c(0, max(dd2)),
col = colors,
colvar = m2,
colkey = FALSE,
axes = FALSE
)
How can I modify this code to ensure that the top plane of each bar in the 3D histogram is square instead of rectangular?
Thank you in advance for your help!
1