## -----------------------------------------------------------------------------
#| label: setup
library(ggplot2)
library(ggindex)


## -----------------------------------------------------------------------------
#| label: data
df <- data.frame(x = 6:10, y = 6:10, id = 1:5)
df$label <- paste0("Label", df$id)


## -----------------------------------------------------------------------------
#| label: label
ggplot(df, aes(x, y)) +
  geom_point() +
  geom_label(aes(label = id), nudge_x = 0.2) +
  theme_minimal()


## -----------------------------------------------------------------------------
#| label: fill
ggplot(df, aes(x, y)) +
  geom_point(aes(fill = label)) +
  geom_label(aes(label = id), nudge_x = 0.2) +
  theme_minimal()


## -----------------------------------------------------------------------------
#| label: workaround
df$legend <- paste0(df$id, ": ", df$label)

ggplot(df, aes(x, y)) +
  geom_point(aes(fill = legend), alpha = 0) +
  geom_point() +
  geom_label(aes(label = id), nudge_x = 0.2) +
  scale_fill_discrete(name = "Index") +
  theme_minimal() +
  theme(legend.key.width = unit(0, "cm"))


## -----------------------------------------------------------------------------
#| label: focus
ggplot(df, aes(x, y, label = id, info = label)) +
  geom_focus() +
  scale_info_discrete("Index") +
  theme_minimal()

