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

Print Cell Labels in Heatmap #42

Closed
talgalili opened this issue Apr 1, 2017 · 17 comments
Closed

Print Cell Labels in Heatmap #42

talgalili opened this issue Apr 1, 2017 · 17 comments

Comments

@talgalili
Copy link
Owner

Like asked here: talgalili/d3heatmap#74

@alanocallaghan
Copy link
Collaborator

I was thinking of adding this, I can have a look today if you're not actively working on it

@talgalili
Copy link
Owner Author

talgalili commented Apr 1, 2017 via email

@alanocallaghan
Copy link
Collaborator

Unfortunately...

geom_GeomLabel() has yet to be implemented in plotly.
If you'd like to see this geom implemented,
Please open an issue with your example code at
https://github.com/ropensci/plotly/issues

For now, I could implement separate mouseover values using cellnote

@alanocallaghan
Copy link
Collaborator

Apologies, that was with geom_label. geom_text works.

@alanocallaghan
Copy link
Collaborator

Seems to work okay thusfar, though unfortunately the mouseover currently hides the main matrix mouseover. Hopefully this is fixable.

Okay, the way I see it, we need a cellnote parameter (the matrix), and a draw_cellnote boolean parameter. By default cellnote will be the input matrix, but can be changed, and draw_cellnote should just decide whether to draw it. cellnote_scale can be dropped, imo, as it's not very useful for our purposes.

We will also need a text color parameter, or we could try to figure out what the cell colour will be based on the value and colour scale, or we could try to use a white outline to make the text readable. Options 2 and 3 are my preferred options. http://stackoverflow.com/questions/10686054/outlined-text-with-ggplot2

I will try to mimic this with plot_ly soon, along with the side_colour_plots

@talgalili
Copy link
Owner Author

talgalili commented Apr 1, 2017 via email

@talgalili
Copy link
Owner Author

So this is basically working, but is there a parameter for choosing the color? or a way to make the text have a halo? (right now the text is in black, which doesn't work with our color scheme).

@alanocallaghan
Copy link
Collaborator

I can add the text color parameter and make it work with plot_method = "plotly" but outline is looking to be trickier. If I don't get it sorted today I'll expose the color parameter and call it a day for 0.9.0

@talgalili
Copy link
Owner Author

talgalili commented Apr 13, 2017 via email

@alanocallaghan
Copy link
Collaborator

Can't add outline to plotly text layers, I'll add an issue over there. For now, it's at least slightly better.

@alanocallaghan
Copy link
Collaborator

@talgalili check out the "autocolor" branch, I implemented a method for predicting the cell color value based on the heatmap's color scale and then testing the luminosity of it (there are probably better ways to calculate luminosity but it's a quick hack for now). It's definitely not a long term solution as it relies on the internal structure of plotly objects.

Do you think this is a useful stopgap while we wait for another method of making the text clear? (outline is still my favourite)

@talgalili
Copy link
Owner Author

Hi @alanocallaghan could you share here a screenshot of how it looks?
It sounds like a much better default than the one currently implemented - thanks.
And I would also prefer the outline, once plotly would implement it :)

@alanocallaghan
Copy link
Collaborator

alanocallaghan commented Apr 14, 2017

There's a slight disparity between the plotly and ggplot2 methods currently due to how I mapped to colours (I found the nearest neighbour for plotly, which does not have exact matches from each heatmap value to a colour, rather than doing linear interpolation - simply to save time)

http://imgur.com/a/3ZF8G

The top is with ggplot2, the bottom with plotly

@alanocallaghan
Copy link
Collaborator

I added interpolation and the colors now match. I also found a bug with heatmaply master which meant color palettes such as RdBu could not be used with plot_method = "plotly", I've pushed a fix to master

@talgalili
Copy link
Owner Author

I looked at the screenshot, it looks much better @alanocallaghan
Can the text be centered? (so it doesn't start at the center but center aligned)?

@alanocallaghan
Copy link
Collaborator

I'll add an argument to control alignment; personally I find this left alignment easier to read for numbers, but it's just a preference

@talgalili
Copy link
Owner Author

ok, then we'll keep it as is.

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

No branches or pull requests

2 participants