Skip to content

Inconsistent colours in filled contour plot #4268

@dmurdoch

Description

@dmurdoch

This bug was reported in https://stackoverflow.com/q/64873086/2554330 where the user couldn't get colours consistent across two graphs. Code here is basically what was posted there.

library(ggplot2)
library(gridExtra)

v <- list()
v[[1]] <- ggplot(faithfuld, aes(waiting, eruptions, z = density)) + stat_contour_filled(breaks=(0:10)*0.005)
v[[2]] <- ggplot(faithfuld, aes(waiting, eruptions, z = 1.1*density)) + stat_contour_filled(breaks=(0:10)*0.005)

do.call(grid.arrange,  v)

Screen Shot 2020-11-17 at 12 28 57 PM

Notice that neither graph lists all bins between the specified breaks, and they are inconsistent about assigning colours to corresponding bins, most obviously at the top end where the first graph leaves out 2 bins and the bottom graph leaves out one.

What I would expect is that if the breaks are specified explicitly, the colour would depend on the specified bins, not just the non-empty ones.

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