Skip to content

Commit d2bbdfe

Browse files
committed
do not attempt to contour with empty data
1 parent 5935bb3 commit d2bbdfe

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

R/stat-density-2d.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ StatDensity2d <- ggproto("StatDensity2d", Stat,
141141
check_installed("MASS", reason = "for calculating 2D density.")
142142
# first run the regular layer calculation to infer densities
143143
data <- ggproto_parent(Stat, self)$compute_layer(data, params, layout)
144+
if (empty(data)) {
145+
return(data_frame0())
146+
}
144147

145148
# if we're not contouring we're done
146149
if (!isTRUE(params$contour %||% TRUE)) return(data)

0 commit comments

Comments
 (0)