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

Add ability to use expressions in multipanelplot x and y labels #96

Merged
merged 4 commits into from
Mar 2, 2023

Conversation

stefaneng
Copy link
Contributor

@stefaneng stefaneng commented Feb 15, 2023

Replace check that forces use of string with more general check that allows for expressions in x/ylab.labels.

Description

Allows expressions in xlab.label and ylab.label in create.multipanelplot

Closes #90

Checklist

  • This PR does NOT contain PHI or germline genetic data. A repo may need to be deleted if such data is uploaded. Disclosing PHI is a major problem.
  • This PR does NOT contain molecular files, compressed files, output files such as images (e.g. .png, .jpeg), .pdf, .RData, .xlsx, .doc, .ppt, or other non-plain-text files. To automatically exclude such files using a .gitignore file, see here for example.
  • I have read the code review guidelines and the code review best practice on GitHub check-list.
  • I have set up or verified the main branch protection rule following the github standards before opening this pull request.
  • The name of the branch is meaningful and well formatted following the standards, using [AD_username (or 5 letters of AD if AD is too long)]-[brief_description_of_branch].
  • I have added the major changes included in this pull request to the CHANGELOG.md under the next release version or unreleased, and updated the date.

Example

Previous behavior

library(BoutrosLab.plotting.general)

p1 <- create.histogram(rnorm(100))
create.multipanelplot(
    plot.objects = list(p1),
    ylab.label = expression(bold('TEST' ~ x^2)),
    xlab.label = expression(bold('TEST' ~ y^2))
    )
#> Error in ylab.label != "": comparison is not allowed for expressions

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

New behavior

library(BoutrosLab.plotting.general)

p1 <- create.histogram(rnorm(100))
create.multipanelplot(
    plot.objects = list(p1),
    ylab.label = expression(bold('TEST' ~ x^2)),
    xlab.label = expression(bold('TEST' ~ y^2))
    )

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

Replace check that forces use of string with more general check that allows for expressions in x/ylab.labels
Saves a check for NULL in the `nchar` expressions.
@stefaneng stefaneng merged commit dfc3ac8 into main Mar 2, 2023
@stefaneng stefaneng deleted the stefaneng-multipanel-expression branch March 2, 2023 16:14
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.

create.multipanelplot does not accept expression() as an argument to the labels
3 participants