Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOT work with legend.position = "inside". #74

Open
whooooong opened this issue Nov 11, 2024 · 1 comment
Open

NOT work with legend.position = "inside". #74

whooooong opened this issue Nov 11, 2024 · 1 comment

Comments

@whooooong
Copy link

The legend did not show up when setting legend.position = "inside".

With the most recent version of ggplot2 and ggbreak.

@veronicar239
Copy link

veronicar239 commented Feb 12, 2025

Yes I also noticed that the legend is missing when using theme(legend.position = c(,)) when trying to place the legend inside the plot while using scale_y_break() - screenshot 1. If I run the same code and comment out the scale_y_break() line then the legend appears as normal - screenshot 2.

packageVersion("ggplot2")
[1] ‘3.5.1’
packageVersion("ggbreak")
[1] ‘0.1.3’

data %>%
drop_na(classKey) %>% #drop_na(class) - still shows NA groups among departments
group_by(Department, class) %>%
dplyr::summarise(
count = n()) %>%
arrange(desc(count)) %>%
head(50) %>%
ungroup() %>%
mutate(class = fct_reorder(class, count, .desc = TRUE)) %>%
ggplot(aes(x=class, y=count, fill = Department)) +
geom_bar(stat = "identity") +
scale_y_break(breaks = c(1000000, 2500000)) + #scale_y_break(c(break_point, max(your_data$value))) # breaks = c(50)
scale_fill_discrete(type = palette_secondary_6_green) +
labs(#title = "Top 50 classes",
x = "Class",
y = "Occurences",
fill = "Department") +
theme_minimal() +
theme(legend.position = c(.85,.31), axis.text.x = element_text(angle = 45, hjust=1))

screenshot 1
Image

screenshot 2

Image

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

No branches or pull requests

2 participants