Skip to content

Conversation

@zeileis
Copy link
Collaborator

@zeileis zeileis commented Sep 10, 2025

Fixes #469

type_text() now converts factor x/y variables to numeric so that it can be used for adding text to barplots etc.

Any potential problems with this for other plot types @grantmcdermott ?

@grantmcdermott
Copy link
Owner

Thanks @zeileis. This looks like an elegant solution.

Any potential problems with this for other plot types @grantmcdermott ?

I'd need to do more testing to know for sure, but one edge (?) case that comes to mind: would this work for adding text on top of dodged barplots where beside = TRUE?

@zeileis
Copy link
Collaborator Author

zeileis commented Sep 10, 2025

Not really. In general you need to re-compute all the aggregations that type_barplot() did internally, including stacking, dodging, etc. So for labeling more complex barplots (or even worse: spineplots) we don't offer much support to the users.

I'm not sure how we could best do so, though. Either type_barplot() and type_spineplot() should offer functionality for this directly - or they should return a suitable data structure with the relevant coordinates. Both is not completely trivial unfortunately.

@grantmcdermott
Copy link
Owner

Got it, thanks. I think this is good to merge as-is, then. I might take a crack at the direct labels issue in a separate PR.

@grantmcdermott grantmcdermott merged commit c17bbd7 into main Sep 10, 2025
3 of 4 checks passed
@grantmcdermott grantmcdermott deleted the type_text_factor branch September 10, 2025 14:32
@zeileis
Copy link
Collaborator Author

zeileis commented Sep 10, 2025

I'm happy to help with the direct labels. I think this would be a useful feature...

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.

Plotting labels on barplots using type_text() fails

3 participants