Skip to content

Conversation

@vincentarelbundock
Copy link
Collaborator

Continued work on removing core computation steps from the tinyplot.R file. Here, I created helper functions to draw the legends, and kept only minimal machinery inside tinyplot().

I also reorganized the code a bit, created a couple helper functions to reduce duplication, and renamed a couple things for consistency and clarity.

I'm sure there are improvements available, but the goal is separation of concern. Then, we can think about simplification/performance/clarity.

Let me know what you think.

@grantmcdermott
Copy link
Owner

Sorry for being slow here; dbreg taking up all of my dev time. I'll try review properly by the end of the weekend.

Copy link
Owner

@grantmcdermott grantmcdermott left a comment

Choose a reason for hiding this comment

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

This looks great, @vincentarelbundock. Sorry it's taken me soo long to get to it. Only minor comments/nits and then I think we can merge.

(Aside: Man, some of this legend code is unwieldy. It sort of grew up organically as I was finding one issue and plugging another. I'd love to take another crack at simplifying the code at some point...)

R/legend.R Outdated
#

# Unit conversion helpers (used extensively throughout legend positioning)
lines_to_npc = function(val) {
Copy link
Owner

Choose a reason for hiding this comment

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

For consitency, I think this function should have the "_x" suffix.

env2env(
settings,
environment(),
c(
Copy link
Owner

Choose a reason for hiding this comment

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

Nit: can we make these alphabetic for easy tracking and editing?

@@ -0,0 +1,229 @@
# Draw vertical gradient legend labels, ticks, and title
Copy link
Owner

Choose a reason for hiding this comment

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

Nit: Can these helper functions come after the main function furthr below (with the params)?

@@ -68,29 +154,28 @@ draw_multi_legend = function(
)
position = "right!"
}

## FIXME: current logic only works for "right!"/"left!" legend
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think this FIXME comment should have been deleted. It's something we may want to revist in the future.

@vincentarelbundock vincentarelbundock merged commit ef3bc1e into grantmcdermott:main Jan 11, 2026
3 checks passed
@vincentarelbundock
Copy link
Collaborator Author

Thanks for the review! Fixed and merged.

@grantmcdermott
Copy link
Owner

grantmcdermott commented Jan 11, 2026

Thanks!

Just one minor request for the future: please use Squash and Merge. That way it's much easier for me to keep track of PR-based regressions and contributions.

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.

2 participants