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

Fix pkgdown example to write plots as tempfiles and read from disk #141

Open
stefaneng opened this issue Jul 20, 2023 · 0 comments
Open
Labels
documentation Improvements or additions to documentation

Comments

@stefaneng
Copy link
Contributor

I had updated pkgdown to print plots directly as a quick fix to render the plots. The temporary paths are still commented out in the man pages. The better way to ensure that the plots render correctly is to read the temp files from disk as a png/pdf/whatever output format and display. See this example for how to do it with PNG. Each image type is unique in how it is read from disk though:

filename <- tempfile('example_shared_colourkey', fileext = '.png');
create.multipanelplot(
    plot.objects = list(p1, p2),
    layout.width = 2,
    layout.height = 1,
    width = 10,
    height = 6,
    resolution = 200,
    legend = list(
        bottom = list(
            fun = colourkey
            )
        ),
    filename = filename
    );

# To ensure that width/height are maintained by github/reprex/pkgdown
# All this does it load and print the png we saved
grid::grid.raster(png::readPNG(filename)

See the full example here: #139

@stefaneng stefaneng added the documentation Improvements or additions to documentation label Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant