Skip to content

Custom legend not working with type = "density" plots #85

@grantmcdermott

Description

@grantmcdermott
library(plot2)

# fails silently
with(
  mtcars,
  plot2(
    x = mpg, by = cyl,
    type = "density", 
    legend = list(x = "bottom!")
  )
)

# fails outright
with(
  mtcars,
  plot2(
    x = mpg, by = cyl,
    type = "density", 
    legend = "bottom!"
  )
)
#> Error in if (names(fargs[["legend"]])[1] == "") names(fargs[["legend"]])[1] = "x": argument is of length zero

Interestingly, this isn't a problem if we feed it a density object directly.

# this works, though
with(
  mtcars,
  plot2(
    x = density(mpg), by = cyl,
    legend = "bottom!"
  )
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions