Geom_linerange issue

Geom_linerange isn't putting out a plot that has data on it.

ggplot(data=diamonds)+geom_linerange(mapping = aes(x=cut,y=depth,ymin=depth,ymax=depth))

returns

What is going wrong?

geom_linerange accepts either x or y, but not both. More likely though, the ymax and ymin you've supplied are the same.

Summarizing the min and max values and providing the summary values to geom_linerange() should do the trick.

diamonds %>%
  group_by(cut) %>%
  summarize(
         min_depth = min(depth),
         max_depth = max(depth)
         ) %>%
ggplot() +
  geom_linerange(aes(x=cut,
                     ymin=min_depth,
                     ymax=max_depth))
ggplot(data = diamonds) +
  geom_linerange(
    mapping = aes(x = cut, y = depth),
    fun.min = min,
    fun.max = max,
    stat="summary"
  )

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.