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

Include image of shape table #6236

Merged
merged 4 commits into from
Jan 28, 2025
Merged

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #4034.

It adds an svg image of the shape table to html docs and a pdf image of the shape table in the pdf docs.
I've checked with devtools::build_manual() that also the pdf documentation looks correct.

The code used for creating the figures is:

nms <- c(
  "square open", "circle open", "triangle open", "plus", "cross", 
  "diamond open", "triangle down open", "square cross", "asterisk", 
  "diamond plus", "circle plus", "star", "square plus", "circle cross", 
  "square triangle", "square", "circle small", 
  "triangle", "diamond", "circle", "bullet", "circle filled", "square filled", 
  "diamond filled", "triangle filled", "triangle down filled"
)
shape <- translate_shape_string(nms)

df <- data.frame(
  x = 0:25 %% 5,
  y = 0:25 %/% 5,
  name = nms,
  shape = shape
)

p <- ggplot(df, aes(x, y)) +
  geom_point(aes(shape = I(shape)), size = 4, fill = "red", stroke = 1) +
  geom_text(
    aes(label = paste0(shape, ":\n", name)),
    vjust = -0.5, size = 10, size.unit = "pt"
  ) +
  scale_y_continuous(transform = "reverse", limits = c(-0.5, 5.1)) +
  scale_x_continuous(limits = c(-0.5, 4.5)) +
  theme_void()

ggsave(
  file.path("man", "figures", "shape_table.svg"), 
  plot = p, device = svglite::svglite, fix_text_size = FALSE, 
  width = 6, height = 4, dpi = 72, bg = "white"
)
ggsave(
  file.path("man", "figures", "shape_table.pdf"), 
  plot = p,
  width = 6, height = 4, dpi = 72, bg = "white"
)

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@teunbrand teunbrand merged commit fa7e2c1 into tidyverse:main Jan 28, 2025
13 checks passed
@teunbrand teunbrand deleted the shape_table branch January 28, 2025 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export pch_table
2 participants