Skip to content

Could position nudging be done in an easy proportional way relative to scale as a whole (e.g. using I function)? #6466

Closed as duplicate of#5609
@davidhodge931

Description

@davidhodge931

It'd be nice to be able to nudge in a proportional way easily. At present, you can calculate your nudge manually in absolute units, but it'd nice if there was a more simple straightforward way.

The I function allows relative positioning when annotating. So was wondering if it'd be possible to support this with nudging? This is adding nudge_x =I(0.05) or position_nudge(x = I(0.05)) to do this, rather than having to manually calculate.

Sorry for all the issues!

library(tidyverse)
library(tidyplots)

#currrently do this 
spendings |> 
  group_by(category) |> 
  summarise(across(amount, sum)) |> 
  ggplot(aes(x = amount, y = category, label = amount)) +
  geom_col() +
  geom_text(nudge_x = 1200 * 0.05) #guessing 1200 is the size of the x scale

  
# # would like to do this
# spendings |> 
#   group_by(category) |> 
#   summarise(across(amount, sum)) |> 
#   ggplot(aes(x = amount, y = category, label = amount)) +
#   geom_col() +
#   geom_text(nudge_x = I(0.05)) 

Created on 2025-05-21 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions