Skip to content
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

Feature request: coord_flip() #39

Closed
JasonPekos opened this issue Oct 20, 2023 · 10 comments
Closed

Feature request: coord_flip() #39

JasonPekos opened this issue Oct 20, 2023 · 10 comments

Comments

@JasonPekos
Copy link

If it doesn't exist already, IMO it would be nice to have coord_flip in tidierplots.

ggplot (R) reference: here.

I can take a look at creating a PR if there's any interest.

@JasonPekos
Copy link
Author

A bit of frustrating news.

As per:

MakieOrg/AlgebraOfGraphics.jl#355
MakieOrg/AlgebraOfGraphics.jl#97

simply the horizontal orientation is not yet supported in AlgebraOfGraphics

It seems more possible with base Makie, but they use at least two different attributes (direction = :x vs orientation = :horizontal ), and it seems like altogether a bit of a mess.

@rdboyes
Copy link
Member

rdboyes commented Oct 27, 2023

There are a lot of frustrating aspects to using AlgebraOfGraphics as the base of this package to be honest - I have considered seeing how difficult it would be to cut it out as a dependency and rely on Makie directly. I really like the interop idea, but I'm not sure how much support AoG is getting at this point, and a lot of its "quirks" are not documented to the extent that I would like .. to be fair, it does say in its description that it should be expected to break often

@kdpsingh
Copy link
Member

kdpsingh commented Oct 27, 2023

@JasonPekos, thanks for the comments and for doing a bit of investigation into this!

In general, we're trying to map TidierPlots to functionality within AlgebraOfGraphics, and in some cases may be able to wrap Makie directly.

Will let @rdboyes weigh in on this when he has time, but please feel free to continue to open issues on any of our packages so we can continue to make them better!

Edit: @rdboyes, you beat me to the reply!

@jkrumbiegel
Copy link

Found this issue while I researched a bit how TidierPlots.jl is set up. I think if you want to reimplement ggplot, relying on AoG is not a good idea. First of all, its maintainer currently doesn't have much time for it, but more importantly, I think it's just more complicated to get ggplot's features to work via AoGs API. AoG was created with the hope that it would be enough to map the positional args of Makie plots to a facetting / grouping engine. But this is not true, as many quirks with many different plotting functions show. For example, the horizontal / vertical thing, functions like errorbars or rangebars that take three arguments but are not three-dimensional, and many more.

It seems more possible with base Makie, but they use at least two different attributes (direction = :x vs orientation = :horizontal ), and it seems like altogether a bit of a mess.

That's true, these keywords have grown a bit organically and have therefore not been assimilated across Makie. But as long as TidierPlots abstracts these away you shouldn't care. If you treat Makie as a relatively low-level drawing engine that is "stupid" and doesn't make assumptions about the data you plot, you'll have a better time I think. All the assumptions / semantics should come from this package, and because AoG defines very few on its own, I don't think it's a good intermediate.

@kdpsingh
Copy link
Member

kdpsingh commented Feb 3, 2024

Thank you for this feedback, @jkrumbiegel. I think the original reason for relying on AoG is that the lift required to implement the intended TidierPlots interface from scratch using Makie seemed like too much, and we wanted to make sure this was a good idea before getting too deep in the weeds.

Even now, the interface is functional to a large degree, though there are rough edges because of the reliance on AoG and subtle differences in the needs of TidierPlots from what is implemented in AoG. We are also working on package docs.

I'll defer to @rdboyes on whether he has the bandwidth or desire to refactor this over time to more directly depend on Makie. I'd love to see it happen but feel our biggest problem is low adoption.

I'm furiously working on a set of tutorials to accompany the Tidier family of packages (more coming soon at https://tidierorg.github.io/TidierCourse/), so my focus right now is in encouraging adoption. Appreciate you weighing in.

@rdboyes
Copy link
Member

rdboyes commented Feb 3, 2024

I think my long term goal for the package is to rely directly on Makie rather than use AoG. The easiest way to do that (I think) will be to use the new Makie spec api introduced in Makie 0.20, but that API isn’t finalized/stable yet so I haven’t put a lot of time into “rewiring” tidierplots to use it. Once it’s finalized it should be relatively easy to convert

@rdboyes
Copy link
Member

rdboyes commented Feb 23, 2024

The majority of the work to remove the AoG dependency is complete and the package is working (ish) without it! The 0.6 release will depend directly on Makie. The current version is in the branch https://github.com/TidierOrg/TidierPlots.jl/tree/makie-only . Many of the geoms are not working anymore right now, but I have geom_point working smoothly and getting the other ones to cooperate shouldn't be too bad

@jkrumbiegel
Copy link

Very cool! Do note though that the SpecApi is still experimental, so you might have more maintenance effort with it in the nearer future if we have to make changes to it. Just looping in @SimonDanisch here for awareness.

@rdboyes
Copy link
Member

rdboyes commented Feb 23, 2024

I saw the warning and was trying to hold off on the rewrite, but inspiration struck :) Most of the code is unlikely to change too much even if the SpecApi changes slightly, since it is largely focused on capturing and translating ggplot lingo to Makie args. I'll keep an eye on it though!

@rdboyes
Copy link
Member

rdboyes commented Feb 27, 2024

Back to the original ask - coord_flip() is now superceded in ggplot for much the same reason that I'm now hesitating to implement it - if you want to flip the coordinates, you can simply reverse the order of the aesthetics, and the backend implementation has to change all of the ticks, labels, etc which adds a lot of room for error. For now, I'm going to focus on making each geom work correctly when you do reverse the order, and if there's a compelling use case for coord_flip that isn't addressed in this way then I'll come back to it

@rdboyes rdboyes closed this as completed Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants