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

New stat: stat_connect() #6329

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6228 and replaces #6231.

It follows the advice in #6231 (comment), where instead of implementing the idea as a position adjustment, it is implemented as a stat. Together with #6326, this should offer greater flexibility than a position adjustment.

The example section rendered:

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2

ggplot(head(economics, 20), aes(date, unemploy)) +
  stat_connect(connection = "hv")

# Setup custom connections
x <- seq(0, 1, length.out = 20)[-1]
smooth <- cbind(x, scales::rescale(1 / (1 + exp(-(x * 10 - 5)))))
zigzag <- cbind(c(0.4, 0.6, 1), c(0.75, 0.25, 1))

ggplot(head(economics, 10), aes(date, unemploy)) +
  geom_point() +
  stat_connect(aes(colour = "zigzag"), connection = zigzag) +
  stat_connect(aes(colour = "smooth"), connection = smooth)

Created on 2025-02-12 with reprex v2.1.1

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.

Feature request: position_step()
1 participant