-
Notifications
You must be signed in to change notification settings - Fork 7
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
Wishlist: Will tinyplot ever support returning a plot object as ggplot2 does? #121
Comments
This raises a side question: instead of basing the new package on base graphics, basing it on |
Out of curiosity, what would be the benefits of that? I imagine it would involve a complete re-write of the current package, so it would be nice to get a sense of the tangible gains before considering. |
Without going into detail, we (https://github.com/StoXProject) have one framework package responsible for producing output files based on results from other packages. We currently rely on ggplot objects but would like to explore lightweight alternatives. |
To add to what's already been said: Unlike the (To follow up on Vincent's point, Nonetheless, here are a few additional points that may be be useful:
library(tinyplot)
plt(Sepal.Length ~ Petal.Length | Species, iris)
p = recordPlot()
dev.off() ## optional: remove plot to show that we're really redrawing it below
replayPlot(p)
|
💯 One further point: An additional handy aspect of |
I was going to open a very similar issue. In my case, I would find it useful because it would make working with |
@b-rodrigues Doesn't save_mtcars_plot = function(filename, width, height) {
png(filename, width = width, height = height)
plt(mpg ~ wt | am, mtcars)
dev.off()
} ? But your question does prompt to wonder if we should perhaps add a file-writing argument to |
You can define a target that simply saves the ggplot into a variable, say |
@grantmcdermott Thanks for the useful info about the recordPlot() and replayPlot(), which I did not know about, and the return object from lattice functions. Surely, many of our users are used to the style of ggplot2, so using lattice would either require some persuasion or some work to make plots look like ggplot2. I will stay tuned on the developments of tinyplot and explore whether recordPlot() can be used for our needs. |
I make frequent use of |
Thinking about this some more, I wonder whether we couldn't just call Mock-up example on a fairly large dataset. library(tinyplot)
myplot = function(...) {
tinyplot(...)
grDevices::recordPlot()
}
data("diamonds", package = "ggplot2")
dp = myplot(
price ~ depth | carat, diamonds,
palette = "agSunset",
pch = 16
) We still can't get away from displaying the initial plot on the user's device (unless we did something clever with a dummy device file location at the same time...) But the "saved" plot is easily re-callable. dev.off()
#> null device
#> 1
dp |
I am looking for a tiny alternative to ggplot2 that allows saving a plot object that can be modified (like using the "+" operator of ggplot2) and plotted (like using print() on a ggplot object) later.
The text was updated successfully, but these errors were encountered: