-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed as not planned
Description
I found a problem with coord_flip. The legend is in the opposite order of an ordered geom (like geom_bar).
I expected the legend and order to appear in the same vertical order.
This was previously reported here, but closed: #704
Here is the code to reproduce the bug:
# Create a sample dataset
df1 <- data.frame(
category = rep(c("A", "B", "C"), each = 3),
subcategory = rep(c("X", "Y", "Z"), times = 3),
value = c(10, 20, 30, 15, 25, 35, 20, 30, 40)
)
# Print the dataset
print(df)
# Create a bar graph using ggplot2 with the fill aesthetic
ggplot(df1, aes(x = category, y = value, fill = subcategory)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Bar Graph with Fill Aesthetic",
x = "Category",
y = "Value",
fill = "Subcategory") +
theme_minimal() +
coord_flip()
Metadata
Metadata
Assignees
Labels
No labels