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

ggsave or other means of saving plots from TidierPlots.jl #20

Closed
joshualeond opened this issue Aug 8, 2023 · 6 comments
Closed

ggsave or other means of saving plots from TidierPlots.jl #20

joshualeond opened this issue Aug 8, 2023 · 6 comments
Labels
good first issue Good for newcomers

Comments

@joshualeond
Copy link

Hi there, I'm trying out TidierPlots.jl and was wondering if there's a recommended way to save a plot?

Thanks!

@joshualeond
Copy link
Author

I see we can get there from using CairoMakie and AlgebraOfGraphics like below but if there's a better route I'm definitely curious to know. Thanks!

p1 = @ggplot(penguins, aes(x = bill_length_mm, y = bill_depth_mm, color = species)) + 
    @geom_point() + 
    @geom_smooth(method = "lm") +
    @scale_x_log10(name = "Log10 Scaled Bill Length") + 
    @scale_y_reverse(name = "Reversed Bill Width")

# https://aog.makie.org/stable/generated/penguins/#Small-intermezzo:-saving-the-plot
CairoMakie.save("figure.png", AlgebraOfGraphics.draw(Layers(p1)), px_per_unit = 3)

@kdpsingh
Copy link
Member

kdpsingh commented Aug 15, 2023

We should absolutely add this. If @rdboyes doesn't have bandwidth, will see if someone else on our team can help with an initial implementation.

@rdboyes
Copy link
Member

rdboyes commented Aug 15, 2023

I don't have the bandwidth this month (unfortunately dissertations don't write themselves) - ideal implementation is probably to add a version of save that takes a GGPlot type. Under the hood it should pretty much work like the code @joshualeond has above. Tagging this as a good first issue since it's pretty straightforward and self-contained, if nobody does it before the end of the month I'll work on it!

@rdboyes rdboyes added the good first issue Good for newcomers label Aug 15, 2023
@rdboyes
Copy link
Member

rdboyes commented Aug 15, 2023

Or maybe for consistency it should be a macro? @ggsave? Both?

@kdpsingh
Copy link
Member

I would keep it as a macro @ggsave() just for consistency with the rest of Tidier and TidierPlots.

@rdboyes
Copy link
Member

rdboyes commented Sep 24, 2023

added in 33238a3

@rdboyes rdboyes closed this as completed Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants