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

legend.grob parameterize legend title y-position #199

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

Conversation

jarbet
Copy link
Contributor

@jarbet jarbet commented Oct 9, 2024

Description

For an example of the issue, see #198. The solution involves parameterizing title.y.coord in legend.grob

Closes #198

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 NEWS under the next release version or unreleased, and updated the date. I have also updated the version number in DESCRIPTION according to semantic versioning rules.

  • Both R CMD build and R CMD check run successfully.

Testing Results

    suppressMessages(devtools::load_all('/Users/jarbet/Documents/git/public-R-BoutrosLab-plotting-general'));
    suppressPackageStartupMessages(library(BoutrosLab.plotting.general));

colourkey.labels <- sapply(
    X = seq(0, 6, 2),
    FUN = function(x) {
        return(as.expression(bquote('10'^-.(as.character(x)))));
        }
    );

legend <- legend.grob(
    legends = list(
        legend = list(
            title = expression(bold(underline('q-value'))),
            continuous = TRUE,
            colours = c('white', 'black'),
            total.colours = 100,
            labels = colourkey.labels,
            cex = 1.3, # label text size
            at = seq(0, 100, length.out = length(colourkey.labels)),
            height = 8
            )
        ),
    label.cex = 1.3,
    title.cex = 1.7,
    title.just = 'left',
    title.fontface = 'bold',
    title.y.coord = 1.3 # new argument
    );

create.scatterplot(
    formula = mpg ~ hp,
    data = mtcars,
    legend =  list( 
        right = list( 
            fun = legend 
            )
        )
    );
Screen Shot 2024-10-09 at 4 39 55 PM

Created on 2024-10-09 with reprex v2.0.2

@jarbet jarbet marked this pull request as ready for review October 10, 2024 16:05
@jarbet jarbet requested review from dan-knight and a team as code owners October 10, 2024 16:05
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.

legend.grob parameterize y position of title
1 participant