-
Notifications
You must be signed in to change notification settings - Fork 34
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
Package issue with alphabetizing #138
Comments
Hi @etbeilfuss, thanks for mentioning this. The problem arises from multiple axes having values in common, in this case The warning about some strata appearing at multiple axes is meant to flag this; i'm sure the warnings in this package could be improved, but i'm not yet familiar with how to write them more informatively. Moreover, this is not an optimal solution, and changes to {ggplot2} in the intervening years might have opened up an opportunity to solve it some other way. I don't have the bandwidth to focus on it right now but i'll library(ggplot2)
library(ggalluvial)
species <- data.frame(
Species = c("Black Ash", "Green Ash", "White Ash", "Balsam Poplar", "Big-Tooth Aspen", "Eastern Cottonwood", "Quaking Aspen", "Paper Birch", "River Birch", "Yellow Birch", "Eastern Red Cedar", "Northern White-Cedar", "Choke Cherry", "Hackberry", "Hop Hornbeam", "Hornbeam", "Mountain-Ash", "Pin Cherry", "Red Mulberry", "Serviceberry", "White Mulberry", "Willow", "American Elm", "Rock Elm", "Siberian Elm", "Slippery Elm", "Bitternut Hickory", "Shagbark Hickory", "Douglas-Fir", "Scotch Pine", "Black Oak", "Northern Pin Oak", "Northern Red Oak", "Black Maple", "Norway Maple", "Red Maple", "Silver Maple", "Blue Spruce", "Norway Spruce", "White Spruce", "Bur Oak", "Chinkapin Oak", "Swamp White Oak", "White Oak"),
Group = c("Ash", "Ash", "Ash", "Aspen", "Aspen", "Aspen", "Aspen", "Birch", "Birch", "Birch", "Cedar", "Cedar", "Dropped", "Dropped", "Dropped", "Dropped", "Dropped", "Dropped", "Dropped", "Dropped", "Dropped", "Dropped", "Elm", "Elm", "Elm", "Elm", "Hickory", "Hickory", "Other Pine", "Other Pine", "Red Oak", "Red Oak", "Red Oak", "Soft Maple", "Soft Maple", "Soft Maple", "Soft Maple", "Spruce", "Spruce", "Spruce", "White Oak", "White Oak", "White Oak", "White Oak") )
# overlap between axis levels
intersect(species$Species, species$Group)
#> [1] "White Oak"
# default plot with `discern = TRUE`
ggplot(data = species,
aes(axis1 = Species, axis2 = Group)) +
geom_alluvium(aes(fill = Group), discern = TRUE) +
geom_stratum(discern = TRUE) +
geom_text(stat = "stratum", discern = TRUE,
aes(label = after_stat(stratum)))+
scale_x_discrete(limits = c("Species", "Group"),
expand = c(0.15, 0.05))+
theme_void()+
theme(legend.position = "none") Created on 2024-12-12 with reprex v2.1.1 |
Note: |
@etbeilfuss a possible fix is implemented in the remotes::install_github("corybrunson/ggalluvial", ref = "discern") |
SOLVED The "discern = TRUE" argument solved the issue. I hadn't thought of the name existing in both columns creating an issue, but it makes sense that it could break something. I appreciate your quick response. Hopefully anyone experiencing this issue in the future will be able to find the solution here. |
Description of the issue
I'm working on a visualization of timber species groupings. I'm taking individual species and grouping them into aggregate groups based on their properties. To best visualize this I'm using ggalluvial. The package seems to be automatically sorting species alphabetically, but when it comes to sorting groups alphabetically, the term "White Oak" seems to be registering above "A" on the list.
If this is a bug, please explain the behavior you want versus the behavior you get, and feel free to add any additional comments.
I want the term "White Oak" to be on the bottom as it would be alphabetically without needing to coerce or trick the package. I think needing to coerce the package should be the rare exception, not the standard approach. Another approach could be to allow the factoring of variables to allow for custom orders. I'm not sure if that's already a feature or not, I wasn't able to find anything on it.
If this is not a bug, please just explain the issue as you see fit!
Reproducible example (preferably using
reprex::reprex()
)desiredPlot
Created on 2024-12-12 with reprex v2.1.1
If this is a bug, please provide as small an example as you can that reproduces it.
If this is not a bug, feel free to drop this section!
The text was updated successfully, but these errors were encountered: