Skip to content

Rewrite of Coord/Project syntax and implementation#151

Merged
thomasp85 merged 30 commits intoposit-dev:mainfrom
thomasp85:issue19-project
Mar 3, 2026
Merged

Rewrite of Coord/Project syntax and implementation#151
thomasp85 merged 30 commits intoposit-dev:mainfrom
thomasp85:issue19-project

Conversation

@thomasp85
Copy link
Collaborator

@thomasp85 thomasp85 commented Feb 23, 2026

Fix #19

This PR represent the last of the major refactoring and syntax updates of the main ggsql clauses. Key points:

  • renames COORD to PROJECT
  • removes unsupported coordinate systems that lingered from the first Claude version
  • removes xlim/ylim
  • Reorganises the code into a clearer module structure with a trait based design for the different coords using the same setup as scales and layers

edit:

Ok, some feature creep happened. Coords are now responsible for declaring their positional aesthetics, however many they have. All of this is now handled by translating positional aesthetics into an internal agnostic representation (pos1, pos2, ...) and manage it with a AestheticContext that gets created based on the plot and passed around. The syntax is now PROJECT aes1, aes2, ... TO coord with the aes1... part being optional but allows the user to control the naming of positional aesthetics

edit2:

This PR bumps into a bunch of vegalite deficiencies, especially surrounding the clip setting which is severely broken in vegalite and cannot be made to work. Also, aspect ratio is not possible in vegalite. Also, polar coordinates don't have axes and background and gridlines (#156)

@thomasp85 thomasp85 marked this pull request as ready for review February 27, 2026 14:33
@thomasp85 thomasp85 requested a review from teunbrand February 27, 2026 14:33
@thomasp85 thomasp85 changed the title Issue19 project Rewrite of Coord/Project syntax and implementation Feb 27, 2026
Copy link
Collaborator

@teunbrand teunbrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got through about half of this PR before the weekend enticed me to unglue myself from my screen. I'll get around reviewing the rest after the weekend

Copy link
Collaborator

@teunbrand teunbrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR is great, I love that we can now have arbitrary position aesthetics, which would pave the way for all sorts of future coords.

A few points to think about:

  • How do we envision the bidirectionality of layers? Currently when we say PROJECT y, x TO cartesian, we don't automatically swap any direction or orientation parameters. Is that something that layers would have to detect?
  • Would we need coord munching for lines/polygons (generally any non-axis-aligned stuff) when we use polar coordinates?
  • If we some day decide want want a pos3/z aesthetic, how difficult would that be with the current setup?

I'm also planning to do away with the intercept aesthetics. We can omit these here already or I can adapt my line PR, but we need to pick.

@thomasp85
Copy link
Collaborator Author

Answering your general questions here:

How do we envision the bidirectionality of layers? Currently when we say PROJECT y, x TO cartesian, we don't automatically swap any direction or orientation parameters. Is that something that layers would have to detect?

From the layer side of things they should just work from the assumption that there is a primary and a secondary position, then we should have facilities to switch these around before and after stats etc. I envision that the layer declare their scale/mapping requirements for the primary and secondary positional aesthetics and then we can automatically detect if we need to switch them around. And then have an escape hatch parameter when we can't deduce it from the mapping (very much like how ggplot2 does it). So e.g. the histogram can always assume that it is binning along the primary positional aesthetic

Would we need coord munching for lines/polygons (generally any non-axis-aligned stuff) when we use polar coordinates?

For now let's ignore it. I think maybe it should be a writer thing because they might handle it differently

If we some day decide want want a pos3/z aesthetic, how difficult would that be with the current setup?

The setup should be count agnostic so pretty easy. Only thing is that we might want layers to declare their minimum and maximum number of positional aesthetics they understand. E.g. points can work with any number, but boxplots only 2

@thomasp85 thomasp85 requested a review from teunbrand March 2, 2026 13:10
Copy link
Collaborator

@teunbrand teunbrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. A small nitpick but won't hurt anyone if unadressed.

@thomasp85 thomasp85 merged commit 07d584c into posit-dev:main Mar 3, 2026
4 checks passed
@thomasp85 thomasp85 deleted the issue19-project branch March 3, 2026 05:35
cpsievert added a commit that referenced this pull request Mar 4, 2026
After #142 and #151, metadata.columns returned internal aesthetic names
(pos1, pos2) and geom defaults (fill, stroke, opacity, etc.) instead of
the original SQL column names from the user's data.

Use label_name() which returns the original SQL column name (stored in
original_name) for Column entries and None for Literal entries, fixing
both issues in one filter_map.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

Consider new clause names for THEME, GUIDE, and COORD

2 participants