Skip to content

Add geom_path_point() and geom_path_line()#141

Merged
dylanhmorris merged 4 commits into
mainfrom
dhm-add-geom-pointpath
May 20, 2025
Merged

Add geom_path_point() and geom_path_line()#141
dylanhmorris merged 4 commits into
mainfrom
dhm-add-geom-pointpath

Conversation

@dylanhmorris

@dylanhmorris dylanhmorris commented May 19, 2025

Copy link
Copy Markdown
Collaborator

The value of these ggplot geoms is in allowing connected paths in which points do not "interrupt" lines from a different group, or vice versa. See the examples in the docs for the new functions, replicated here via reprex

library(forecasttools)
library(ggplot2)
library(tibble)
data <- tribble(
    ~x,      ~y,   ~z,
     1,       0,  "a",
     2,       0,  "a",
     3,    -0.5,  "a",
     1,    0.01,  "b",
     3,   -.520,  "b",
     2,     0.02,  "b")
    
 # standard approach causes points to "interrupt"
 # lines when overplotted
 ggplot(data, aes(x = x, y = y, color = z)) +
    geom_path(linewidth = 2) +
    geom_point(size = 5)

 # using a single-layer approach fixes this
 ggplot(data, aes(x = x, y = y, color = z)) +
    geom_path_point(linewidth = 2, size = 5)

 # The same is true for `geom_line` and `geom_line_point`
 # multi-layer approach:
 ggplot(data, aes(x = x, y = y, color = z)) +
    geom_line(linewidth = 3) +
    geom_point(size = 5)

 # single-layer approach:
 ggplot(data, aes(x = x, y = y, color = z)) +
    geom_line_point(linewidth = 3, size = 5)

Created on 2025-05-19 with reprex v2.1.1

@dylanhmorris
dylanhmorris requested a review from damonbayer as a code owner May 19, 2025 23:48
@damonbayer
damonbayer requested a review from Copilot May 20, 2025 14:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Files not reviewed (5)
  • NAMESPACE: Language not supported
  • R/geom_path_point.R: Language not supported
  • man/GeomPathPoint.Rd: Language not supported
  • man/draw_key_path_point.Rd: Language not supported
  • man/geom_path_point.Rd: Language not supported

@dylanhmorris
dylanhmorris merged commit bd442af into main May 20, 2025
@dylanhmorris
dylanhmorris deleted the dhm-add-geom-pointpath branch May 20, 2025 14:50
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

Successfully merging this pull request may close these issues.

3 participants