Skip to content

Can't control the color representation with set data range #87

@IceGe

Description

@IceGe

Hello there,

Really love the d3heatmap package! Only have one problem when try to control the color representation with set data range.
I have a matrix with rows being different groups, columns being all the variables they answered.
Data range from 1 to 4. But continuous variables, meaning it can be 1.11,1.12,2.15, etc.
And although the min the value can be is 1, max can be is 4. But for each group, usually they would not have the full range of data.

The problem is, I created very interactive d3heatmap with ShinyApp which would allow the user to add or delete one or more groups from the huge matrix. In that way, the min and max value keep changing and causing the color assigned to the same value changing too.

I tried to define the breaks like what we can usually use in heatmap.2. (See below)

palette <- c("#D01822","#DE412D","#EC5E3A","#F67C47","#FB9B54", "#FDB767",
                 "#FECF7A","#FAE28A","#E9E989", "#D4ED87", "#BCE277","#A2D769",
                 "#83CA66","#64BC62", "#44AA59","#1A9850")
breaks <- c(1,1.2,1.4,1.6,1.8,2,
                2.2, 2.4, 2.6, 2.8, 3,
                3.2, 3.4, 3.6, 3.8, 4)
colorFunc <- col_bin(palette, bins = rescale(breaks))
d3heatmap(df,1, dendrogram = "none",colors = colorFunc)

I thought since I defined different colors for different data range, the color for a certain value should not change by changing the min, max of the matrix.
However, if I add one more group with extreme low value comparing to other existing groups, the colors are still different for the same value.

By any chance you have any idea about why this is happening or how can i solve this problem?
Any suggestion would be helpful!

Thanks so much!
Ice

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