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

Allow "by" convenience keyword for pch and bty args #28

Merged
merged 4 commits into from
Apr 16, 2023
Merged

Conversation

grantmcdermott
Copy link
Owner

Fixes #27.

Tl;DR Users can opt into varying by groups along pch and lty via the "by" convenience keyword. The possibility for manual adjustment (#5) should still work the same, but this makes the process a bit less error prone from the user side.

Quick examples:

library(plot2)

plot2(
  Temp ~ Day | Month,
  data = airquality,
  type = "l",
  col = "black", # override automatic group colours
  lty = "by"     # change line type by group instead
)

# Should automatically respond (and recycle if necessary) to global par settings

par(pch=16)
plot2(
  Temp ~ Day | Month,
  data = airquality,
  type = "b",
  palette = "Tableau 10",
  pch = "by", # pch adjustment should be from 16 onwards
  lty = "by"
)

Created on 2023-04-15 with reprex v2.0.2

- Also Name chunks to avoid needless git diff when positions change
@vincentarelbundock
Copy link
Collaborator

Oh, I get it now! Users can still feed a vector manually to lty, but using the "by" shortcut string calculates the number of groups automatically.

This is very very nice! Well done.

@zeileis
Copy link
Collaborator

zeileis commented Apr 16, 2023

🚀

@grantmcdermott
Copy link
Owner Author

Great. Happy for me to merge?

@grantmcdermott grantmcdermott merged commit 1e99ab9 into main Apr 16, 2023
5 checks passed
@grantmcdermott grantmcdermott deleted the by-keyword branch April 16, 2023 14:13
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.

should pch and lty vary by group?
3 participants