Skip to content

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

Closed
@jpquast

Description

@jpquast

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions