Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure that can be added to aesthetic specifications vignette on annotation adjustments #5164

Closed
mine-cetinkaya-rundel opened this issue Jan 28, 2023 · 2 comments

Comments

@mine-cetinkaya-rundel
Copy link
Member

We're taking the following figure out of R4DS to save space and thought it might be a useful addition to https://ggplot2.tidyverse.org/articles/ggplot2-specs.html.

#| label: fig-just
#| echo: false
#| fig-width: 4.5
#| fig-asp: 0.5
#| out-width: "60%"
#| fig-cap: >
#|   All nine combinations of `hjust` and `vjust`.
#| fig-alt: >
#|   A 1x1 grid. At (0,0) hjust is set to left and vjust is set to bottom. 
#|   At (0.5, 0) hjust is center and vjust is bottom and at (1, 0) hjust is 
#|   right and vjust is bottom. At (0, 0.5) hjust is left and vjust is 
#|   center, at (0.5, 0.5) hjust is center and vjust is center, and at (1, 0.5) 
#|   hjust is right and vjust is center. Finally, at (1, 0) hjust is left and 
#|   vjust is top, at (0.5, 1) hjust is center and vjust is top, and at (1, 1) 
#|   hjust is right and vjust is bottom.

vjust <- c(bottom = 0, center = 0.5, top = 1)
hjust <- c(left = 0, center = 0.5, right = 1)

df <- crossing(hj = names(hjust), vj = names(vjust)) |>
  mutate(
    y = vjust[vj],
    x = hjust[hj],
    label = paste0("hjust = '", hj, "'\n", "vjust = '", vj, "'")
  )

ggplot(df, aes(x, y)) +
  geom_point(color = "grey70", size = 5) +
  geom_point(size = 0.5, color = "red") +
  geom_text(aes(label = label, hjust = hj, vjust = vj), size = 4) +
  labs(x = NULL, y = NULL)

image

@teunbrand
Copy link
Collaborator

There is already the figure below that shows a very similar thing. I like that the text has two lines that makes it easier to see the justification, but it also adds a degree of visual clutter.

@teunbrand
Copy link
Collaborator

I'll close this for now, as the topic is already covered in the vignette, but thank you Mine for the considerate proposal!

@teunbrand teunbrand closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants