Dear Researchers
I try to o plot a 3D heat map for yield in R studio
I have four experimental factors:
Heat stress with four levels 24, 30, 34, 38°c
2Level for drought stress: non-drought and Drought stress
Two levels for treatment timing Flowering stage and seed filling stage
Two levels for a treatment duration of 6 and 12 days.
The dataset for this example is attached
I use (plotly) package, and the code is as follows:
# Step 1: Create a 3D scatter plot
scatter_plot %
add_markers() %>%
layout(scene = list(xaxis = list(title = "Heat stress"),
yaxis = list(title = "Drought stress"),
zaxis = list(title = "Yield")))
# Step 2: Create a 3D surface plot
surface_plot %
add_surface() %>%
layout(scene = list(xaxis = list(title = "Heat stress"),
yaxis = list(title = "Drought stress"),
zaxis = list(title = "Yield")),
title = "3D Heat Map with Surface for Yield")
# Step 3: Customize the 3D plot
scatter_plot %>%
layout(title = "3D Scatter Plot of Yield",
scene = list(camera = list(eye = list(x = -1.5, y = -1.5, z = 1))),
margin = list(l = 0, r = 0, b = 0, t = 50)) %>%
add_annotations(text = "Treatment Duration", x = 0.5, y = -0.1, showarrow = FALSE)
surface_plot %>%
layout(scene = list(camera = list(eye = list(x = -1.5, y = -1.5, z = 1))),
margin = list(l = 0, r = 0, b = 0, t = 50),
coloraxis = list(colorbar = list(title = "Treatment Timing", x = 0.95, y = 0.5)
# Step 4: Create a 3D surface plot with opacity
surface_plot %
add_surface(opacity = 0.8) %>%
layout(scene = list(xaxis = list(title = "Heat stress"),
yaxis = list(title = "Drought stress"),
zaxis = list(title = "Yield")),
title = "3D Heat Map with Surface for Yield")
I got this errror code (Error: `z` must be a numeric matrix.
Can anybody help to solve this error
I will appreciate every suggestion, thank you!