Hello I am trying to create a simple contour plot.
x and y has to be generated from uniform distribution only. It cannot be generated in equally spaced grid.
The output is empty plot with labels in return with warning messages -
1: stat_contour(): Zero contours were generated
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
Can someone please fix it. Thanks
library(tidyverse)
x <- runif(1000, min = -5, max = 5)
y <- runif(1000, min = -5, max = 5)
z <- x^2 + y^2
tbl <- tibble(x, y, z)
# plot VOTT
ggplot(data = tbl,
aes(x = x,
y = y,
z = z)) +
geom_contour_filled(alpha = 0.8) +
scale_fill_viridis_d(drop = FALSE) +
theme_bw() +
theme(legend.position = "right") +
theme(aspect.ratio = 1) +
ggtitle("Trial") +
guides(color = guide_legend(override.aes = list(size = 2))) +
theme(legend.title = element_text(size = 8),
legend.text = element_text(size = 8))