-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ragg device functions not working with ggsave #4347
Comments
Thanks, I too faced this problem a while ago. As the default value of Lines 181 to 185 in dbd7d79
|
This is the lookup table that converts file extensions into graphic devices, so it wouldn't have an effect if users specify the graphics device as a function. Instead, if they do so, they will have to set However, we should change the lookup table so it uses ragg devices by default if available. |
See also: #4086 |
Yeah — the plan is to use ragg if available for all file types where it makes sense in the next release. If someone is eager to implement the logic they should feel free but otherwise I'm on it the next time I look at ggplot2 |
Yes, what I meant was the users need to define some wrapper function like the one below. I guess a lot of people will use AGG as RStudio graphic device (as it's great) and they'll want to use the same rendering on library(ggplot2)
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, col = Species)) + geom_point()
# 300 is the same dpi as ggsave()'s default
png <- function(...) ragg::agg_png(..., res = 300, units = "in")
ggsave("gg_test.png", p, device = png) |
The behaviour of |
The following works just fine, though. If people want to use custom graphics devices they need to be prepared to set a few parameters correctly, I think. Maybe the real issue is to document library(ggplot2)
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, col = Species)) + geom_point()
ggsave("~/Desktop/gg_test.png", p, device = ragg::agg_png, res = 300, units = "in")
#> Saving 7 x 5 in image Created on 2021-02-22 by the reprex package (v1.0.0) |
@clauswilke, when I run your example, my FWIW, My session info:
|
Hello, In addition, it seems that
(This is solved by explicitly calling |
@collioud |
I can confirm w/ @taraskaduk that using Claus' exact code with
However, providing additional arguments to
|
Ah, this makes sense. |
Yup! I can confirm you can get the "expected" behavior as so, without specifying arguments inside
This is still a bit tricky to read as |
…ents in passed in device
In the recent tidyverse blogpost "Modern Text Features in R" it states you can use the ragg device functions with ggsave:
It's not working for me however, the following code results in an empty image being saved.
Related to r-lib/ragg#69
Created on 2021-02-17 by the reprex package (v1.0.0)
Session info
Thanks.
The text was updated successfully, but these errors were encountered: