Skip to content

geom_path(linejoin = "mitre") #2399

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

Closed
behrman opened this issue Jan 13, 2018 · 9 comments
Closed

geom_path(linejoin = "mitre") #2399

behrman opened this issue Jan 13, 2018 · 9 comments

Comments

@behrman
Copy link

behrman commented Jan 13, 2018

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

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()

@batpigandme
Copy link
Contributor

Thanks, Bill. Just adding my snippets from the community thread since I have them, so it'll (hopefully) be easier to navigate sources when we troubleshoot.

Exact replication of the example using linejoin = "mitre" from the doc example

# 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 🔎: 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().

@Ax3man
Copy link
Contributor

Ax3man commented Jan 15, 2018

The documented example works as expected for me on 2.2.1. Using differently sized segments (as in OPs example) never works, as the segments get connected by size and therefore respond to the lineend parameter, not the linejoin.

@batpigandme
Copy link
Contributor

Interesting, the CRAN version (2.2.1) works as expected (see reprex below), but the dev version does not (shown in #2399 (comment), above, tidyverse/ggplot2@3fb3fb0)

# 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")

@batpigandme batpigandme added the bug an unexpected problem or unintended behavior label Jan 15, 2018
@Ax3man
Copy link
Contributor

Ax3man commented Jan 15, 2018

Possibly related to 3553f31?

@batpigandme
Copy link
Contributor

@Ax3man good call. 👍 Works as it should when linemitre = 1 is passed as an argument. @behrman, your example doesn't work, but, as mentioned, I think that has to do with the change in size at the line joins.

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", linemitre = 1)

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

n.b. When passed linemitre = 10, it appears un-mitred. (@hadley, not sure if this is what's meant by better matching base R, per the comment in 3553f31).

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", linemitre = 10)

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

@behrman
Copy link
Author

behrman commented Jan 15, 2018

Yes, mitering works when the line segments are the same size, but doesn't work when the segments are of different sizes. Is there any way to get this to work for segments of different sizes?

I'm using ggplot2 2.2.1.9000.

Thanks

@hadley
Copy link
Member

hadley commented Jan 15, 2018

I don't think so - the underlying grid grob doesn't support varying widths.

@batpigandme batpigandme removed the bug an unexpected problem or unintended behavior label Jan 19, 2018
@batpigandme
Copy link
Contributor

Since it sounds like this isn't possible, I'm gonna go ahead and close the issue.

@lock
Copy link

lock bot commented Jul 18, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants