Geom_path(linejoin = "mitre")

ggplot2

#1

The code below does not mitre the path segments as in the geom_path() documentation.

Could you please tell me how I might get this to work?

Many thanks,

Bill

suppressMessages(library(tidyverse))

tibble(x = 0:2, y = c(0, 1, 0), size = c(8, 4, 4)) %>% 
  ggplot(aes(x, y, size = size)) +
  geom_path(linejoin = "mitre") +
  scale_size(range = c(4, 8)) +
  coord_fixed()


#2

Hmm… Interesting, I’m seeing the same thing. For similicity’s sake, I think the exact replication of the example using linejoin = “mitre” from the example is probably most useful to show. I’m also going to use reprex to show the problem (always a good way to go):

# Control line join parameters
library(ggplot2)
df <- data.frame(x = 1:3, y = c(4, 1, 9))
base <- ggplot(df, aes(x, y))
base + geom_path(size = 10, linejoin = "mitre", lineend = "butt")

Created on 2018-01-13 by the reprex package (v0.1.1.9000).

And the example with the same code from the docs:
Example of linejoin mitre from ggplot2 docs

Bonus forensic investigation :mag_right:: I checked out the ggplot2 repo, and looked for issues mentioning mitre or linejoin. The most recent was 2014, however, the pull request that closed it wasn’t long ago. Then I looked for the most recent mention of linejoin in NEWS.md (4 years ago), searched for “linejoin”, found somewhat recent changes for linejoin in geom_segment.R, but, this was in geom_path(). However, that doesn’t necessarily mean they’re unrelated.

I could probably investigate further, but, I think it makes sense to open an issue.


#3

Mara,

This is my first post to the RStudio Community, and I’m very grateful for your prompt reply, your research, and your suggestions.

I’ve submitted a ggplot2 issue.

Many thanks!

Bill


#4

Perfect! Thanks for pointing it out— issues can be an excellent source of QA.