Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ggplot2 (development version)

* Extent the range of the line created by `geom_abline()` so that line ending
is not visible for large linewidths (@thomasp85, #4024)

* Make sure that default labels from default mappings doesn't overwrite default
labels from explicit mappings (@thomasp85, #2406)
Expand Down
6 changes: 6 additions & 0 deletions R/geom-abline.r
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ GeomAbline <- ggproto("GeomAbline", Geom,
draw_panel = function(data, panel_params, coord) {
ranges <- coord$backtransform_range(panel_params)

if (T || coord$clip == "on" && coord$is_linear()) {
# Ensure the line extends well outside the panel to avoid visible line
# ending for thick lines
ranges$x <- ranges$x + c(-1, 1) * diff(ranges$x)
}

data$x <- ranges$x[1]
data$xend <- ranges$x[2]
data$y <- ranges$x[1] * data$slope + data$intercept
Expand Down