Skip to content

Legend positions#70

Merged
Olivia-Box-Power merged 10 commits into
developmentfrom
legend_positions
Feb 23, 2026
Merged

Legend positions#70
Olivia-Box-Power merged 10 commits into
developmentfrom
legend_positions

Conversation

@aronnyberg
Copy link
Copy Markdown
Collaborator

Added top-left(-0.2) and top-right(1) options for legend setting, . Ran devtools::document so description updated.

@aronnyberg aronnyberg self-assigned this Feb 3, 2026
@Olivia-Box-Power
Copy link
Copy Markdown
Collaborator

Olivia-Box-Power commented Feb 4, 2026

Thanks @aronnyberg!

Changes look good. I've updated the branch to make it up to date with the development branch.

Could you please

  • Update the news file
  • Add yourself as a contributor in the description file
  • Add a few tests in the "theme_af works with non default options" section of tests/testthat/test-chart-output.R

In the following example, the legend title ("class") is cut off

ggplot(mpg, aes(x = class, colour = class)) + geom_bar() +theme_af(legend = "top-left")

Could we also add in a bottom-left and bottom-right legend option? I suppose we could also have a top, middle and bottom option for left and right?

Could also look at the theme legend.title.position?

Merge branch 'development' into legend_positions

# Conflicts:
#	R/theme_af.R
#	man/theme_af.Rd
@Olivia-Box-Power Olivia-Box-Power linked an issue Feb 4, 2026 that may be closed by this pull request
@Olivia-Box-Power
Copy link
Copy Markdown
Collaborator

Just to note, its possible to set positions for top/left/right/bottom legends individually in theme. You can also set the position of the legend title.

ggplot(
  mpg, aes(x = class, colour = class, fill = as.character(class))) +
  geom_bar() +
  guides(
    fill = guide_legend(position = "top"),
    colour = guide_legend(position = "left")
  ) +
  theme(
    legend.justification.left = c(0, 0.1),
    legend.justification.top = c(0.9, 0),
    legend.title.position = "top"
  )

@Olivia-Box-Power Olivia-Box-Power changed the base branch from main to development February 13, 2026 11:53
@Olivia-Box-Power Olivia-Box-Power requested review from zac-gleisner and removed request for Olivia-Box-Power February 23, 2026 11:19
@Olivia-Box-Power Olivia-Box-Power merged commit e8dac4d into development Feb 23, 2026
7 checks passed
@Olivia-Box-Power Olivia-Box-Power deleted the legend_positions branch February 23, 2026 11:42
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.

Allow more options for legend position in theme_af

3 participants