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

New format of calls to agg_png in ggsave break scaling function: #69

Closed
andrewbaxter439 opened this issue Jan 14, 2021 · 4 comments
Closed

Comments

@andrewbaxter439
Copy link

andrewbaxter439 commented Jan 14, 2021

Related to #66 - the updated format for calls of agg_png in ggsave breaks the ggsave code in @thomasp85's plot scaling walkthrough.

These commands produce the same size/resolution image:

library(ggplot2)
library(ragg)

p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, col = Species)) + geom_point()

ggsave("test1.png",
       p,
       device = agg_png( 
       width = 10,
       height = 5, 
       units = "cm",
       scaling = 1,
       res = 200))
#> Saving 3.94 x 1.96 in image

ggsave("test2.png",
       p,
       device = agg_png( 
       width = 40,
       height = 20, 
       units = "cm",
       scaling = 4,
       res = 200))
#> Saving 3.94 x 1.97 in image

Whereas these work as expected (with same arguments outside of ggsave:

library(ggplot2)
library(ragg)

p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, col = Species)) + geom_point()


agg_png("test1.png", 
        width = 10,
        height = 5, 
        units = "cm",
        res = 200)
print(p)
dev.off()

agg_png("test2.png",
        width = 40, 
        height = 20,
        units = "cm", 
        res = 200,
        scaling = 4)
print(p)
dev.off()

Created on 2021-01-14 by the reprex package (v0.3.0)

@thomasp85
Copy link
Member

where have you seen this "updated format" being advertised?

@andrewbaxter439
Copy link
Author

andrewbaxter439 commented Jan 14, 2021

ah good question, was just going off other issue (#66) where it's assumed to be a change. Putting the arguments to pass to agg_png outside of the brackets don't seem to work as expected:

ggsave("test.png",
       p,
       device = agg_png, 
       width = 10,
       height = 5,
       units = "cm",
       res = 100)

... produces an image 3px*1px. Putting these parts in the brackets does produce the image the correct size, but scaling argument within agg_png brackets within ggsave doesn't work as expected. Apologies if I'm misunderstanding this (and other issue is unrelated).

@andrewbaxter439 andrewbaxter439 changed the title New format of calls to agg_reg in ggsave break scaling function: New format of calls to agg_png in ggsave break scaling function: Jan 21, 2021
@thomasp85
Copy link
Member

I'm not sure if ggsave() handles ragg correctly to be honest, but that is an issue for ggplot2, not ragg 🙂

@andrewbaxter439
Copy link
Author

andrewbaxter439 commented Feb 8, 2021

Thanks @thomasp85 - can look more into it and open a ggplot2 issue if there's still a problem. Was excited to find a way of mastering scaling plots but still trying to figure out some parts of it 😄

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

No branches or pull requests

2 participants