Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

geom_step does not work when group has exactly one point #719

Closed
mwts opened this Issue · 2 comments

2 participants

@mwts

Using R and ggplot2 version 2.15.1

d <- data.frame(x=1:3,y=1:3,g=c('a','a','b'))
ggplot(d, aes(x=x,y=y, color=g)) + geom_point() + geom_step()

# Error in isIncomplete(con) : invalid connection
# Error in isIncomplete(con) : invalid connection
# Error in grid.Call.graphics(L_lines, x$x, x$y, index, x$arrow) : 
#   invalid line type

The same occurs with geom_line() in place of geom_step()
I would expect that geom_step simply draw nothing when group has size 1

@mwts

Same behavior for geom_density: works when group has size 2 or more, but throw an error when size is exactly 1

d <- data.frame(x=runif(100),f=factor(c(0,0,1,rep(2,97))))
ggplot(d, aes(x=x,fill=f)) + geom_bar()       # OK
ggplot(d, aes(x=x,fill=f)) + geom_density()
## Error in rowSums(vapply(x, is.finite, logical(nrow(x)))) : 
##         'x' must be an array of at least two dimensions
## Error in UseMethod("scale_dimension") : 
##         no applicable method for 'scale_dimension' applied to an object of class "NULL"
ggplot(subset(d,f!=1), aes(x=x,fill=f)) + geom_density() # OK
@hadley
Owner

This sounds like a great feature, but unfortunately we don't currently have the development bandwidth to support it. If you'd like to submit a pull request that implements this feature, please follow the instructions in the development vignette.

@hadley hadley closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.