Skip to content

Incorrect shading / colors  #44

@jeroen

Description

@jeroen

A user reported that the colors and shading in ragg is off. Here is a minimal example:

library(tidyverse)
library(ragg)

# generate data
group.a <- tibble(values = rnorm(n = 1000, mean = 0, sd = .3),
                  group = "group.a")
group.b <- tibble(values = rnorm(n = 1000, mean = 0, sd = .2),
                  group = "group.b")
group.c <- tibble(values = rnorm(n = 1000, mean = 0, sd = .1),
                  group = "group.c")
combined <- full_join(group.a, group.b)
combined = full_join(combined, group.c)

makeplot <- function(){
  ggplot() +
    scale_x_continuous(limits = c(-1, 1), breaks = c(-1, -.5, 0, .5 , 1)) +
    stat_density(data = combined, aes(x = values, y = factor(group), fill = group, alpha =  stat(density)), geom = "raster", position = "identity") +
    scale_fill_manual(values = c("#BF1E2E" , "#E6C949" , "#2AB9C1")) +
    scale_alpha_continuous(range = c(0.005, 1)) +
    geom_point(data = combined, aes(x = 0, y = group), size = 5, shape = 21, colour = "black", fill = "grey 95")
}


png(filename = "cairo.png", width = 1080, height = 720, res = 144)
makeplot()
dev.off()

agg_png(filename = "ragg.png", width = 1080, height = 720, res = 144)
makeplot()
dev.off()

Base / Cairo

cairo

Ragg

ragg

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions