Skip to content

Error in scale_index[[i]]: subscript out of bounds when we have layers with different datasets and facets with free scales #3099

Closed
@smouksassi

Description

@smouksassi

When having a composite ggplot with a data subset per layer setting scales = "free" gives an error.
What is fundamentally wrong with this approach ?
setting scales to fixed don't produce an error

require(ggplot2)
#> Loading required package: ggplot2
ggplot(mtcars, aes(mpg, disp)) + facet_grid(~cyl,scales="free") + 
  geom_point() +
  geom_point(data = subset(mtcars, cyl == 4)) +
  geom_line(data = subset(mtcars, cyl == 6)) +
  geom_text(data = subset(mtcars, cyl == 8), aes(label = gear))
#> Error in scale_index[[i]]: subscript out of bounds

ggplot(mtcars, aes(mpg, disp)) + facet_grid(~cyl,scales="fixed") + 
  geom_point() +
  geom_point(data = subset(mtcars, cyl == 4)) +
  geom_line(data = subset(mtcars, cyl == 6)) +
  geom_text(data = subset(mtcars, cyl == 8), aes(label = gear))

Created on 2019-01-24 by the reprex package (v0.2.1)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions