Skip to content

Factor/categorical color symbology in plots #27

Open

Description

@RobertSellers

Are there any methods for allowing a set # of categorical colors for ggplots? Everything defaults as a continuous color range.

Activity

  1. Swarchal commented on Feb 3, 2021

    @Swarchal
    Owner

    Yeah it's not documented very well, but you can pass strings or factors to raw_map.

    e.g:

    df = data.frame(
        well = num_to_well(1:96),
        sample_name = sample(c("a", "b", "c"), 96, replace=TRUE)
    )
    
    raw_map(
        well = df$well,
        data = df$sample_name,
        plate = 96
    )

    plot

  2. RobertSellers commented on Feb 4, 2021

    @RobertSellers
    Author

    Ah - no this should have been obvious to me. I had some custom symbology running through it which was the error...

    + scale_fill_viridis()

  3. RobertSellers commented on Feb 4, 2021

    @RobertSellers
    Author

    Hi again. I just wanted to follow-up with something related. Is it possible to add these discrete labels to the well fills? Using your example - placing an "a" over all of the red wells. Is this possible with platetools or does this require some very custom work?

  4. Swarchal commented on Feb 4, 2021

    @Swarchal
    Owner

    Good question, and another undocumented workflow. You can add labels using geom_text() from ggplot.

    library(platetools)
    library(ggplot2)
    
    df = data.frame(
        well = num_to_well(1:96),
        sample_name = sample(c("a", "b", "c"), 96, replace=TRUE)
    )
    
    raw_map(
        well = df$well,
        data = df$sample_name,
        plate = 96
    ) + 
        geom_text(aes(label=df$sample_name))

    plot2

  5. RobertSellers commented on Feb 4, 2021

    @RobertSellers
    Author

    Excellent, thank you. This is looking quite good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions