Skip to content
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

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

Open
IceGe opened this issue May 22, 2018 · 0 comments
Open

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

IceGe opened this issue May 22, 2018 · 0 comments

Comments

@IceGe
Copy link

IceGe commented May 22, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant