You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a few packages where I now have to add a Suggests: on ggplot2 simply because a demo plots a (micro)benchmark as violin plots via the autoplot feature.
That would be lighterweight with tinyplot but I don't see violin plots around, or discussed/proposed. Has this come up? Is this feasible especially in the nice autoplot sense of visualizing a benchmarking comparison?
This is a good shout. Should be pretty straightforward to repurpose some of our existing type_density code for it. I'll take a crack this weekend if I get time.
RE: autoplot-alike for microbenchmark. Perhaps we can convince @joshuaulrich to add a tinyplot method once we fix this violin plot support.
isn't quite where autoplot(res) (with res <- microbenchmark(....) ) is, but then that also is a whole function with some other helpers. And Rome and one day and all that.
I think we essentially need to fix the scale of type_ridge() and then draw the mirrored density as well. Except for the mirroring this plot is quite close:
f <- function() NULL
res <- microbenchmark(NULL, f(), times = 100)
tinytheme("minimal")
tinyplot(expr ~ log(time), data = res, type = type_ridge(scale = 1, joint.bw = FALSE))
For type_violin() I would switch the roles of x and y compared to type_ridge(). Thus, y should be the numeric variable and x the grouping variable as in type_boxplot(). So the plot above would have to be generated with flip = TRUE.
Instead of visualizing log(time) we would want a logarithmic axis of time. However, in that case I have to make sure that (a) the bandwidth is selected appropriately and (b) the limits do not become negative.
Side remark: It seems that in type_ridge() we cannot change the ylim. Otherwise I would have decreased the lower limit so that the two plots look more similar...
Just thinking out loud here: might it make sense to add an entrypoint and wrapper for, say, microbenchmark results here rather than going the two-step route of offering and interface and have a partner package fill it in?
Just thinking out loud here: might it make sense to add an entrypoint and wrapper for, say, microbenchmark results here rather than going the two-step route of offering and interface and have a partner package fill it in?
As a general rule, I think we should avoid shipping generic methods for non-base packages as much as possible within tinyplot, and rather let package owners handle it themselves. Achim's recent addition of a default zoo.tinyplot method provides a good example that could be emulated by other packages. https://r-forge.r-project.org/scm/viewvc.php/pkg/zoo/R/tinyplot.zoo.R?pathrev=1198&root=zoo
One thing that would be helpful in the meantime: Which of the geom_violin or panel.violin defaults would folks like to see re-used for this tinyplot implementation (trim, width, etc.)?
Good question. My gut feeling would have been to not trim (as in lattice). But I guess that they thought about why the do trim by default for ggplot2...
Some people, myself included, like trimmed means to summarise benchmark runs. Other people, most famously @mattdowle when he was still involved in things, argue for final M of N total runs to discard warm up and cache effects. Cannot please all the people all the time...
Okay, official PR for type_violin support here: #354
I'd appreciate some tire kicking if you get the time, @eddelbuettel and @zeileis. For my part, I think that the PR is in pretty good shape. I should also say that I'm still in the middle of a very busy stretch at work, and can't promise to allocate much more time to this in the short run. If you both feel that the current PR is "good enough", or if only minor changes are required, then we can go ahead and merge. But more substantial re-writes will have to wait a couple of weeks, at least.
BTW realized on morning run I should also try boxplot (which somehow never entered for these benchmark comparison, maybe we all should converge on (jittered) dotplots?) to see how it fares with the outlier. In short, not great either -- and this one then gets the y-axis labels wrong (under two themese):
Activity
grantmcdermott commentedon Mar 23, 2025
This is a good shout. Should be pretty straightforward to repurpose some of our existing
type_densitycode for it. I'll take a crack this weekend if I get time.RE: autoplot-alike for
microbenchmark. Perhaps we can convince @joshuaulrich to add atinyplotmethod once we fix this violin plot support.eddelbuettel commentedon Mar 23, 2025
It would need some handholding. A naive
isn't quite where
autoplot(res)(withres <- microbenchmark(....)) is, but then that also is a whole function with some other helpers. And Rome and one day and all that.joshuaulrich commentedon Mar 23, 2025
I'm happy to add one, especially if it's as simple as merging a PR ;)
zeileis commentedon Mar 24, 2025
I think we essentially need to fix the
scaleoftype_ridge()and then draw the mirrored density as well. Except for the mirroring this plot is quite close:Caveats:
type_violin()I would switch the roles ofxandycompared totype_ridge(). Thus,yshould be the numeric variable andxthe grouping variable as intype_boxplot(). So the plot above would have to be generated withflip = TRUE.log(time)we would want a logarithmic axis oftime. However, in that case I have to make sure that (a) the bandwidth is selected appropriately and (b) the limits do not become negative.type_ridge()we cannot change theylim. Otherwise I would have decreased the lower limit so that the two plots look more similar...grantmcdermott commentedon Mar 24, 2025
I started working on an implementation in https://github.com/grantmcdermott/tinyplot/tree/type_violin.
Still needs quite a bit of work, but the basic functionality is there.
Created on 2025-03-24 with reprex v2.1.1
zeileis commentedon Mar 24, 2025
Nice, thanks for this! Looks very nice already.
Quick comment: I think the
joint.maxargument is needed here as well.eddelbuettel commentedon Mar 24, 2025
Nice (and fast) work.
Just thinking out loud here: might it make sense to add an entrypoint and wrapper for, say,
microbenchmarkresults here rather than going the two-step route of offering and interface and have a partner package fill it in?grantmcdermott commentedon Mar 25, 2025
As a general rule, I think we should avoid shipping generic methods for non-base packages as much as possible within
tinyplot, and rather let package owners handle it themselves. Achim's recent addition of a defaultzoo.tinyplotmethod provides a good example that could be emulated by other packages. https://r-forge.r-project.org/scm/viewvc.php/pkg/zoo/R/tinyplot.zoo.R?pathrev=1198&root=zooeddelbuettel commentedon Mar 25, 2025
@grantmcdermott Close:
A log axis would be nice,log="y"works too, but some smarts for unit scaling the time measurement would be nice.grantmcdermott commentedon Mar 25, 2025
Nice. Yeah, I can imagine submitting a PR to Josh's repo that looks something like:
eddelbuettel commentedon Mar 25, 2025
Yep. Noodled minimally with 'ipsum' and
yielding
(from a fresh ad-hoc session so
reshad changed but same expression as above).PS It should say "ms" not "ns". And be scaled. But that part, as you say, may come from
PPS Just running helpers
determine_unitandconvert_to_unitgets usres$ntimeand thenyielding
grantmcdermott commentedon Mar 25, 2025
Crunch time at work ATM. I’ll try to pick this up again towards the end of the week(end).
grantmcdermott commentedon Mar 25, 2025
One thing that would be helpful in the meantime: Which of the geom_violin or panel.violin defaults would folks like to see re-used for this
tinyplotimplementation (trim,width, etc.)?zeileis commentedon Mar 26, 2025
Good question. My gut feeling would have been to not trim (as in lattice). But I guess that they thought about why the do trim by default for ggplot2...
eddelbuettel commentedon Mar 26, 2025
Some people, myself included, like trimmed means to summarise benchmark runs. Other people, most famously @mattdowle when he was still involved in things, argue for final M of N total runs to discard warm up and cache effects. Cannot please all the people all the time...
grantmcdermott commentedon Mar 31, 2025
Okay, official PR for
type_violinsupport here: #354I'd appreciate some tire kicking if you get the time, @eddelbuettel and @zeileis. For my part, I think that the PR is in pretty good shape. I should also say that I'm still in the middle of a very busy stretch at work, and can't promise to allocate much more time to this in the short run. If you both feel that the current PR is "good enough", or if only minor changes are required, then we can go ahead and merge. But more substantial re-writes will have to wait a couple of weeks, at least.
eddelbuettel commentedon Apr 1, 2025
BTW realized on morning run I should also try boxplot (which somehow never entered for these benchmark comparison, maybe we all should converge on (jittered) dotplots?) to see how it fares with the outlier. In short, not great either -- and this one then gets the y-axis labels wrong (under two themese):
I can open a new ticket if you want...
grantmcdermott commentedon Apr 1, 2025
Thanks @eddelbuettel, please do. The lhs margin should be correctly adjusted for those horizonal y-axis labels.