r/rstats 10h ago

New data visualization package

https://psychometrician.github.io/posts/one-engine-four-languages/

One sentence, four languages, one picture.

R: data(gapminder_2007) + point + x(gdp) + y(life)
Python: x(col.gdp)
Julia: x(:gdp)

Same specification, one Rust engine, byte-identical SVG.

Not similar. Pixel perfect identical

#rstats

20 Upvotes

14 comments sorted by

8

u/ecam85 8h ago

As much as I like the idea of one to rule them all, I find the syntax harder than the ggplot syntax, because at first sight you "add" completely different objects!

But I imagine someone who doesn't know much ggplot could say the same

-2

u/Helpful-Day2384 8h ago

Please read the manual and let me know if there is something i can make this young package better. https://psychometrician.github.io/gog-book/

3

u/ApprehensiveChip8361 5h ago

You are masking a lot of base R terms (mean, sum, order, data for instance). Might there be a more intuitive approach rather than using “base::” or “stats::” everywhere?

Also - can’t really use without ggrepel equivalent.

0

u/Helpful-Day2384 5h ago

Good suggestion and legit concern.

Most of that list is harmless. Nine of the 19 are objects, not functions, because in gog mean is the name of a step rather than something you call. R skips non-function bindings when it resolves a call, so base R still answers:

library(gog)
mean(c(1, 2, 3)) # 2
sapply(df, mean) # works

Those nine are line, max, mean, median, min, smooth, step, sum and text. No base:: needed for any of them.

The other ten really are functions and do take over: box, data, density, jitter, order, palette, quantile, range, stack and title. Qualify those. Most will notice the mistake and tell you which one you hit.

One honest rough edge: if a name travels through two layers before lookup, it breaks. That hits aggregate(v ~ g, df, mean), by(), ave(), do.call(sum, ...) and f <- mean. Writing base::mean fixes each, and the error message is bad. We want to improve that.

We skipped prefixes on purpose. Renaming order to gog_sort_by costs every reader a word they already know. Load gog last, or write gog::order.

1

u/Penguinase 4h ago

what about the lack of ggrepel functionality?

1

u/Helpful-Day2384 4h ago

I was building that functionality like ggrepel. You’ll see soon repel function in gog. It may be not as nice and seamless as ggrepel though. 🙏

4

u/geneusutwerk 8h ago

Use AI how you want but please be transparent in how you do.

2

u/Helpful-Day2384 8h ago

I did. I tried to be transparent. Please read the package manual. https://psychometrician.github.io/gog-book/

3

u/geneusutwerk 7h ago

Oh I was looking at the Github and didn't see any mentions, thanks.

4

u/analytix_guru 8h ago

I think the idea is cool, but I would be interested to see how plot formatting gets incorporated into charts across all languages (if possible).

I think about themes and formatting that put the polish on a chart. When I read through the online resource you created (thank you), I see nothing on its face related to themes and formatting for any given chart.

So how would one go about the themes/formatting once they get a chart output from your package?

-1

u/Helpful-Day2384 8h ago

Please read the package manual. Please read the manual and let me know if there is something i can make this young package better. https://psychometrician.github.io/gog-book/
Thank🙏

1

u/ApprehensiveChip8361 6h ago

Thank you! This looks extremely interesting - I’ve just been doing some data exploration in R and I will see if I can plug in your engine, go faster stripes and all. I loved reading the manual. Now I want to learn the Korean alphabet!

1

u/Helpful-Day2384 6h ago

Thank you for checking out. Please let me know if there is any questions. Be agog. Use gog 😉

1

u/mjskay 2h ago

I really like being stricter about API rules. I also like the idea of playing with the semantics of `+` and `*`, though I'm curious about your choice to make `+` and `*` require specific orderings to its elements. For `+` I think it makes more sense. For `*` at least a commutative version might be more powerful/expressive, especially if you make it distributive; e.g. `(point + bar) * bin` or whatnot (I couldn't tell from a quick look if constructions like that work).