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

linewidth of panel.border and axis.line not identical #6057

Closed
jpquast opened this issue Aug 25, 2024 · 1 comment
Closed

linewidth of panel.border and axis.line not identical #6057

jpquast opened this issue Aug 25, 2024 · 1 comment

Comments

@jpquast
Copy link

jpquast commented Aug 25, 2024

I came across an inconsistency in the line thickness of the panel.border and axis.line. I am not sure if it is a bug or a user error, but I couldn't really make sense of it.
If I set the line width with the linewidth argument the resulting lines are different even if the same value is supplied. The documentation of element_rect() and element_line() says the unit should be "mm". I am not sure which of the two is correct.

Help would be really appreciated! Thanks a lot in advance!

library(ggplot2)

ggplot(data = data.frame(x = 0, y = 0), aes(x = x, y = y)) +
  geom_blank() + 
  theme_minimal() + 
  theme(
    panel.border = element_rect(colour = "black", fill = NA, linewidth = 10),
    axis.line = element_line(colour = "black", linewidth = 10),
    axis.text = element_blank(),
    axis.title = element_blank(),
    panel.grid = element_blank()
  ) 

Created on 2024-08-25 with reprex v2.1.1

@clauswilke
Copy link
Member

Half of the panel border is cut off by clipping.

library(ggplot2)

p <- ggplot(data = data.frame(x = 0, y = 0), aes(x = x, y = y)) +
  geom_blank() + 
  theme_minimal() + 
  theme(
    panel.border = element_rect(colour = "black", fill = NA, linewidth = 10),
    axis.line = element_line(colour = "black", linewidth = 10),
    axis.text = element_blank(),
    axis.title = element_blank(),
    panel.grid = element_blank()
  )

p

p + coord_cartesian(clip = "off")

Created on 2024-08-25 with reprex v2.0.2

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

No branches or pull requests

2 participants