I have a matrix with NA values on the y-axis at the “0.75” point, but when I plot the contour plot, the blank area of the graph comes up at the “10” and “10.75” point.
I am pretty sure it is because of my scaling in my axis (which I have done using a specified equation from plotly), but don’t know where I am going wrong. The other blank areas in the contour plot are correct and are NA values.
Here is the dataframe, WW3_MF
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
NA -1.5 -1.0 -1.0 NA 0.5 -1.0 -1.0 -1.5 -3.0
NA -1.5 -1.0 -0.5 0.0 1.0 -1.0 -1.0 -2.0 -4.0
NA -1.5 -1.0 -1.0 1.0 NA 0.0 -1.0 -2.5 -4.5
NA -1.5 -1.0 -1.0 NA 1.5 NA -1.0 -3.0 -4.5
NA -1.0 -1.0 -0.5 1.0 1.5 -1.0 -1.0 -2.5 -4.5
NA -1.5 -2.0 -0.5 1.0 2.0 -2.0 -1.0 -3.0 -5.0
NA -1.5 -2.0 -0.5 0.5 1.5 -2.0 -1.5 -3.0 -4.5
NA -1.5 -2.0 -1.0 -0.5 1.5 -2.5 -1.0 -3.0 -4.5
NA -0.5 -1.0 NA 1.0 NA -3.5 -1.0 -3.0 -4.5
NA -0.5 -1.5 -1.0 0.0 2.5 -3.5 0.0 -3.0 -4.5
NA -1.0 -1.0 -0.5 -0.5 2.5 NA -0.5 -3.0 -5.5
NA -0.5 -1.5 0.5 -1.0 3.0 -4.0 0.5 -2.5 -5.0
NA -0.5 -1.0 -0.5 -1.5 3.0 -4.5 0.5 -2.5 -5.0
NA -0.5 -1.5 -0.5 NA 2.5 -3.5 0.0 -2.5 -4.5
NA 0.0 -1.0 NA -2.0 3.0 -2.5 -0.5 -2.5 -4.0
NA 0.0 -1.0 -1.0 -1.5 3.5 -3.0 0.5 -3.0 -4.0
NA 0.5 -0.5 -1.5 NA 2.5 -2.0 0.5 -2.5 -4.0
NA 0.5 0.5 0.5 -1.0 2.5 -1.0 1.0 -2.0 -4.0
NA 0.5 0.5 0.5 -1.0 3.0 -1.0 1.0 -2.0 -3.5
NA -1.0 0.5 0.0 0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3.5
NA 1.0 -1.0 -1.0 -1.5 -2.5 -3.0 -1.0 -3.0 -3.0
NA 1.5 -0.5 -1.0 -1.0 -3.0 -2.5 -1.0 -2.5 -3.0
NA 1.0 -1.5 -1.0 -1.5 -3.0 -3.0 -1.5 -4.0 -2.5
Here is my R-script.
p <- plot_ly(z = matrix(c(WW3_MF)), type="contour", width=500, height=1074, colorbar = list(title = "Accumulation/Erosion (cm)"),
colorscale=list (c(0, "rgb(0,0,255)"),list(0.65, "rgb(135,206,250)"), list(0.75, "rgb(255,255,0)"), list(0.85, "rgb(255,165,0)"), list(1, "rgb(255,0,0)")),zauto=F, zmin=-14, zmax=8) %>%
layout(title="WW3_MF",
yaxis=list(title="Y(m)", tickmode = "array",ticktext = c("-0.75", "-0.1", "0.1", "0.5","1.5", "2.5", "5", "7.5", "10", "10.75"),tickvals = c("1", "1.51", "1.67", "1.98","2.76", "3.54", "5.5", "7.46", "9.41", "10"),range = c(1,10)),
xaxis=list(nticks="4",title="X(m)",tickmode = "array",ticktext = c("1", "2", "3"),tickvals = c("15", "30", "45"),range=0,45), shapes =list(type = "rect",line = list(color = "black"), x0 = "0", x1 = "22.5", xref = "x",y0 = "0.58", y1 = "8.41", yref = "y"))
(contours = list(z =list(show=TRUE, usecolormap=TRUE,highlightcolor="#ffA500",project=list,countourlabels="TRUE")))
(scene = list(camera=list(eye = list(x=1.87, y=0.88, z=-0.64))))p
Here is the contour plot.
Here is the second contour plot with a range (0,9) and tickvals = c("0", "0.509", "0.665", "0.978","1.761", "2.543", "4.5", "6.457", "8.413", "9")

