Skip to content

Support type = "segments"#163

Merged
grantmcdermott merged 6 commits intomainfrom
segments
Jul 7, 2024
Merged

Support type = "segments"#163
grantmcdermott merged 6 commits intomainfrom
segments

Conversation

@grantmcdermott
Copy link
Owner

Closes #162.

Examples:

pkgload::load_all("~/Documents/Projects/tinyplot/")
#> ℹ Loading tinyplot
set.seed(42L)
x = stats::runif(12); y <- stats::rnorm(12)
i = order(x, y); x <- x[i]; y <- y[i]
s = seq(length(x)-1)  # one shorter than data
s = s[-length(s)]
grp = rep(LETTERS[1:2], 5)

plt(
  xmin = x[s], ymin = y[s], xmax = x[s+2], ymax = y[s+2],
  by = grp,
  type = "segments"
)

# also vary lty and lwd by groups
plt(
  xmin = x[s], ymin = y[s], xmax = x[s+2], ymax = y[s+2],
  by = grp,
  lty = "by", lwd = "by",
  type = "segments"
)

# xmin = xmax
plt(
  xmin = x[s], ymin = y[s], xmax = x[s], ymax = y[s+2],
  by = grp,
  lty = "by", lwd = "by",
  type = "segments"
)

# ymin = ymax
plt(
  xmin = x[s], ymin = y[s], xmax = x[s+2], ymax = y[s],
  by = grp,
  lty = "by", lwd = "by",
  type = "segments"
)

Created on 2024-07-07 with reprex v2.1.0

@grantmcdermott grantmcdermott merged commit 2d67407 into main Jul 7, 2024
@grantmcdermott grantmcdermott deleted the segments branch July 7, 2024 21:25
@grantmcdermott grantmcdermott mentioned this pull request Jul 7, 2024
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.

"segments"

1 participant