我看到几篇关于改变 ggplot中线宽的帖子.答案虽然对OP有效且有效,但会改变线条大小.也就是说,ggplot似乎将线条视为一系列单位,并且尺寸增加了每个单元的长度和宽度,使得其他调整更粗糙.
我希望有一种方法可以使线条更宽(更厚)而不会影响长度,反过来又会影响破折号.
我从https://cran.r-project.org/web/packages/ggplot2/vignettes/ggplot2-specs.html借用了一些代码来说明我的意思:
library(ggplot2)
#A simple plot with manually set dashes.
#The first numeral is units of dash length, the second units in the gap in hexadecimal.
lty <- c("11", "18", "1f", "81", "88", "8f", "f1", "f8", "ff")
linetypes <- data.frame(y = seq_along(lty), lty = lty)
ggplot(linetypes, aes(0, y)) +
geom_segment(aes(xend = 5, yend = y, linetype = lty)) +
scale_linetype_identity() +
geom_text(aes(label = lty), hjust = 0, nudge_y = 0.2) + …Run Code Online (Sandbox Code Playgroud)