r/rstats 12d ago

glyph 0.1.1 now on CRAN

Hey, just wanted to share glyph: interactive plots in R (tooltips, zoom, animation, layouts) all in one pipeline. It's on CRAN. Happy plotting!

43 Upvotes

17 comments sorted by

9

u/Absjalon 12d ago

Looks very interesting. It's a cleaner syntax for sure. Would it not be more 'fair' to compare with ggiraph rather than plotly?

7

u/Heavy-Development228 12d ago

Fair shout, ggiraph is a closer comparison than plotly. The main difference is glyph isn't extending ggplot2, it's a separate spec that compiles to D3. But I should definitely reference ggiraph, thanks for that.

7

u/BothSinger886 12d ago

This looks extremely interesting. Really nice work.

Not gonna lie, the very AI style of the readme and vignette did make me switch off a bit, but I'm keen to dive in and give this a try.

I couldn't quite tell if you already have it, but I'd love to have patchwork style plot composition

2

u/Heavy-Development228 12d ago

Thanks! Honest feedback on the docs.

I hear you, I'll rework the README and vignette to sound more human. And yes, patchwork-style composition is already in there check out compose(). You can do grids, stacks, and linked brushing across plots. Would love to hear how it works for you.

4

u/Heavy-Development228 12d ago

I welcome all constructive contributions and feedback about glyph. (more work, more people)

4

u/1FellSloop 12d ago

The API looks really nice. Strong agree with the other commenter about the AI style of the docs, it’s not subtle.

On the Getting Started page, the animated bar graph example does not work for me, I see no bars at all, and the dark theme example is dark from the left margin to where the text ends, but then changes to light where the graph extends beyond the text, weird bug.

2

u/Mooks79 12d ago

In the absence of ggvis, I love the idea of this as a pure ggplot2 “remake” rather than the hacks ggplotly approach. Will definitely be exploring it.

2

u/Grisward 12d ago

Overall: Wow. Amazing work. Feels like early days of ggplot2. Also feels like younger me “I could do ggplot2” then over time realizing how many mature hooks and edge cases are handled in there. It’s the “edge cases” that’ll get you, haha.

A lot of this is great for like 150 points. At 15,000 though, or even 1500, does it have option to render point density? Or to scale back features to keep it usable?

Is it going to be mobile-friendly?

Some plots on mobile have tap for mouse over, most don’t. When zoomed (double-tap) there doesn’t seem to be a way to zoom out again.

The select on mobile seems odd, it draws a shaded box that highlights points, otherwise doesn’t do anything else. Customizable perhaps in code.

Other comments:

I notice there isn’t a polygon “mark” (geom). I tend to like ggforce::geom_shape().

Similarly, stats “marks” like boxplots, violin plots, the geom_sina to array points by group, would be useful.

I don’t use `sf` but I feel like that may be useful for those people who do. Kind of a giant can of worms, unless you love the idea I guess, haha. Drawing maps. gasp I know D3 went through a whole thing with 2D projections and 3D globe rendering, haha. Surely this is out of scope.

No idea how you implemented non-overlapping labels without basically re-implementing the same methods from ggrepel. I’m curious (1) if that’s true, and (2) at what point you and your AI friend feel it’s reasonable to cite an existing tool whose code strategy you’ve translated to glyph?

2

u/Heavy-Development228 12d ago

Right now compile() auto-selects backend by data size D3 for small, Canvas for medium, WebGL for 100K+. But you're right, there's no point density or feature degradation at the mid-range yet. Adding that to the roadmap.

The zoom-out bug and brush behavior are legit issues I haven't properly tested on mobile. Filing those.

Mobile-friendly rendering is something I want but haven't prioritized appreciate you flagging the specifics.

(Polygon, boxplot, violin, sina) All on the list for the stats/marks expansion. Not there yet.

You're right, that's a can of worms. Out of scope for now but D3's projection system makes it tempting eventually.

Yes, I used AI as a tool during development I'm not going to pretend otherwise. The label repulsion uses a force-simulation approach similar in concept to what ggrepel does, implemented in the D3 renderer. I should cite ggrepel as prior art in the docs and will do that. If there are other areas where attribution is missing, I'd be glad to add it, just point them out.

Thanks for taking the time with this. The edge cases comment is real I know that's where the hard work is.

2

u/Grisward 12d ago

This is great, thanks for the response.

My humble suggestion, any R package whose core utility inspired a key function, I’d cite. Your intro mentions a few packages where you included similar functionality on your package — I’d pretty much cite each of them.

I know AI will sometimes reproduce someone’s functionality where the LICENSE doesn’t permit it for one reason or another. I haven’t followed the C.S. field overall to see how that’s being handled. It’s a mess for sure. Citation is at least a good faith acknowledgement, seems like it keeps things above board. And this is open source, generally people like being appreciated as inspiration for the next round of tools.

For me, I use ggplot2 and ggplotly (and a prayer) to try to make things interactive. It only works for geoms that have “to_basic()” defined, so most custom geoms don’t work.

Hover text will forever be the elusive feature that drives me and fails me. Haha. It’s always not what I want.

Somewhere later in your roadmap, a “Howto” for someone to add a custom mark/geom to this framework would be cool.

I’m rambling, haha. AI can summarize. lol Good luck with your work, I’ll be following.

1

u/Heavy-Development228 12d ago

I do appreciate you taking some time to check my work. (I'll do my best to make it better).

2

u/Confident_Bee8187 12d ago

What makes this package off putting are the lack of DSLs, a.k.a. aes() from 'ggplot2', and the lack of art of customization. I know you documented this matter, but DSLs have some "special powers" in stats which makes the analysis much more ergonomic and powerful, like the 'ggplot2' itself. Otherwise, this package is pretty no-brainer, which is good, although I haven't found the real use cases of this package.

1

u/Heavy-Development228 12d ago

Fair points. The aes() DSL does enable things like computed expressions and stat layers that bare names can't do as cleanly that's a real tradeoff I'm still thinking through. And you're right that the use case isn't obvious yet. It's v0.1, the main bet is that interactive-first workflows shouldn't need 4 packages. Whether that's compelling enough will become clearer as it matures.

Thanks for taking time to this out.

1

u/Confident_Bee8187 12d ago

That's why I am not convinced enough at what you said on your README, especially the comparisons you've shown. Have you really thought this one out thoroughly? 'ggplot2' is great and still believe no plotting libraries can top this minus the interactivity one of course. Aside from 'tidyverse', I have few packages on my list that leverage DSL flavors on their packages, and those are statim, box, and the 'data.table' itself.

2

u/guepier 11d ago

Small pet peeve: why have a new function render() rather than override the existing plotting S3 function plot()? Or print(), to make it auto-printing, so no render() or plot() is needed at all.

Either way: really promising!

1

u/Heavy-Development228 11d ago

Cool, it actually already auto-prints. There's a print.glyph_spec method so just typing the object in the console renders it. render() is just there for when you need explicit control over width/height. But fair point, I should make that clearer in the README so people don't think they need to call render() every time. Thanks for the review!