1

I'm trying to add directlabels to lines of a ridgeline plot created by ggridges. It seems directlabels doesn't know what to apply the labels to. Is it possible to specify this? Or are the two packages incompatible?

# does not work
ggplot2::ggplot(iris,
                ggplot2::aes(x = Sepal.Length, y = Species, height = Sepal.Width)) +
  ggridges::geom_density_ridges(stat = "identity") +
  directlabels::direct.label("first.points")

Error in UseMethod("direct.label") : 
  no applicable method for 'direct.label' applied to an object of class "character"
# does not work
ggplot2::ggplot(iris,
                ggplot2::aes(x = Sepal.Length, y = Species, height = Sepal.Width)) +
  ggridges::geom_density_ridges(stat = "identity") +
  directlabels::direct.label.ggplot("first.points")

Error: $ operator is invalid for atomic vectors
4

0 回答 0