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
Change in ggsave behaviour #4513
Comments
Honestly, I've never seen anybody do this, and it's definitely not a supported feature to my knowledge. The only reason that it worked is probably that You were relying on the fact that The valid way to do what you want to do is this code:
This is the commit that caused the change in behavior: 23baab0 |
Well, that certainly never was a feature — I'm surprised it ever worked in the first place... it is hard to anticipate when someone's hack stops to work which is also why it hasn't been communicated. I don't suspect many have used this hack based on the fact that this is the first time I've seen it, but I could be wrong |
Honestly I never thought I was doing a hack, but I understand this was the case. But still, with the new changes in R 4.1 and ggplot 3.3.4 I can do: data.frame(a = rnorm(100), b = rnorm(100)) |>
ggplot(aes(a, b)) +
geom_point() |>
ggsave(file = "temp.png") But the mixing of pipes and + is prone to errors, so I don't know if it would be a good idea to add a feature of "adding" to ggsave. You find more information about what I mean in the response I got in stackoverflow. |
Can we just add a NEWS item and close this issue? If so, I'll address this in #4518. |
Fine by me. There's already a bullet about the invisible return value of ggsave so maybe just add it there ? |
Thanks, added. Does this sound good?
|
I still think that the hack adheres more to the adding/piping philosophy than having a ggsave floating around somewhere after the plot, but you can close it, yes, thanks. |
I think that sounds fine, yeah |
@ecorreig @thomasp85 |
* Increment version number * Revert R-CMD-check.yaml * Add a NEWS item for #4513
I used |
@acircleda when we say that it is a hack we do not necessarily imply any ill-intend on the user, just that it is an accidental functionality that was never promised to work. The fact that some have used it does not really change our stance on it. adding ggsave did not stop working because we decided to remove the functionality, but because internal wanted changes resulted in the hack stopping to work - such is the nature of hacks. I can certainly emphasise with your situation but I hope you can understand that development would be completely locked down if we were to take all unintended uses of our code into consideration when fixing bugs etc |
This is indeed very anti-intuitive. Implicit arguments (i.e. taking last plot) are also a prone to problems when working interactively. Not sure if developers follow how most users believe the code should behave, but if so, |
ggplot2 from version 3.3.4 onwards does not support adding ggsave as an object to a plot. This should be a fix. Needs to be tested before a pull request can be sent. https://ggplot2.tidyverse.org/news/index.html and tidyverse/ggplot2#4513
I used to "add" ggsave("something.png") to a ggplot object but this has stopped working after version 3.3.3. In case it's been decided that this "feature" wasn't a good idea and the removal was on purpose, please better document that change (even if the possibility to do + ggsave() wasn't documented before; I think many people used it because it might the pipes very elegant).
In short, this worked on 3.3.3:
But throws this error on 3.3.4:
The text was updated successfully, but these errors were encountered: