- 
 
- 
  Notifications
 You must be signed in to change notification settings 
- Fork 2.7k
Annotated heatmap #359
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
Annotated heatmap #359
Conversation
 @cldougl
 
 cldougl
 
 
 
 commented
 Nov 25, 2015 
 
 
 
- add annotated heatmaps and tables to FigureFactory
- add FF option for annotated heatmaps with logical text colouring - users can supply a matrix of text for annotations otherwise the value from the z matrix is used - add FF option to create a table (defaults to striped table) - input options are a z matrix or a pandas data frame - option for user to supply table colours and font colours
- add validation functions and tests for annotated_heatmap and tables - add docstrings for all functions - fix annotated_heatmap annotations so the font color logic is followed when a text matrix is supplied.
@cldougl - ready for review?
@chriddyp the code is but I'm making a notebook of examples for you guys now
- doc examples - add hover text option for annotated heatmaps
@chriddyp @theengineear @etpinard 
Annotated Heatmaps and Tables are ready for review! Here are a few use examples: http://nbviewer.ipython.org/gist/cldougl/d746349aa58ab1eca55c 
 
 
 plotly/tools.py
 
 Outdated
 
 
 There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chriddyp I thought these colors looked pretty good for the default table colors but I'm super open to other suggestions
- changed `text` to `annotation_text` and `table_text` so the `text` argument can still be used for hover - cleaned up arg names and order
super sweet @cldougl :):))
A few issues/thoughts:
- numpy error:
>>> iplot(FF.create_annotated_heatmap(np.random.randn(20, 20))) ----> 1 iplot(FF.create_annotated_heatmap(np.random.randn(20, 20))) /Users/chriddyp/Repos/python-api/plotly/tools.py in create_annotated_heatmap(z, x, y, text, hover_text, fontcolor, showscale, **kwargs) 2605 FigureFactory._validate_annotated_heatmap(z, text) 2606 annotations = _AnnotatedHeatmap(z, x, y, text, fontcolor, -> 2607 **kwargs).make_annotations() 2608 2609 if x or y: /Users/chriddyp/Repos/python-api/plotly/tools.py in make_annotations(self) 3775 yref='y1', 3776 font=dict(color=min_text_color if val < -> 3777 (max(max(self.z))-min(min(self.z))) / 2 3778 else max_text_color), 3779 showarrow=False)) ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
-  Is it safe to shrink down the margins on the tables since they don't have axes labels? It'll look nice n flush in ipython notebooks that way (looks like you'll need to do some adjustments on the rows, though)
 image
ok @chriddyp @theengineear sorry for that false alarm earlier- it's ready now!
http://nbviewer.ipython.org/gist/cldougl/45285a3b01e81023f7ae 
- no problems for the margins (I'll edit that and lower the row constant)
- wasn't testing with numpy :( shouldn't be a big deal to incorporate- I'll fix that now and add a test
It's sweet that dataframes just work!
from datetime import datetime
import pandas.io.data as web
df = web.DataReader("aapl", 'yahoo', datetime(2007, 10, 1), datetime(2009, 4, 1))
iplot(FF.create_table(df))
- remove margins from tables
I like the default table colors, but @jackparmer or @delekru might have an opinion
image 
Could we split the first example in Tables into two example? One that is just text, and the next that includes the colorscale and fontcolor updates?
image 
yep np!
 
 
 
 delekru
 
 
 
 commented
 Nov 25, 2015 
 
 
 
small adjustment suggestions:
suggestions 
Just because the light blue on black looks funny to me.
Nice! +1 on Derek's colors. Looks like Fornightly Thoughts
http://www.goldmansachs.com/s/esg-impact/assets/downloads/Fortnightly_Thoughts_The_changing_parts_of_Europe.pdf 
On Wed, Nov 25, 2015 at 2:34 PM, derek lu notifications@github.com wrote:
small adjustment suggestions:
[image: suggestions]
https://cloud.githubusercontent.com/assets/11370069/11407511/4f8a5714-9381-11e5-9b4c-8005d36d8b77.pngJust because the light blue on black looks funny to me.
—
Reply to this email directly or view it on GitHub
#359 (comment).
thanks @delekru ! I like defaulting to a darker header color w/ white font and using black in the table
Can we have an additional example with tables with  links and
LaTeX? 
On Wed, Nov 25, 2015 at 2:41 PM, Chelsea notifications@github.com wrote:
thanks @delekru https://github.com/delekru ! I like defaulting to a
darker header color w/ white font and using black in the table—
Reply to this email directly or view it on GitHub
#359 (comment).
@jackparmer yep 👍
- add numpy compatibility - change default table colors - fix for average calculation happening in `make_annotations` - update tests to reflect changes - break up example 1 in table docstring To-Do [ ] update table test to reflect new colours [ ] update table fontcolor logic so `if index` the column font color matches header font color
Ooooohhh, also a subplot of a chart plus a table side-by-side. That one
comes up a lot.
On Wed, Nov 25, 2015 at 3:03 PM, Chelsea notifications@github.com wrote:
@jackparmer https://github.com/jackparmer yep [image: 👍]
—
Reply to this email directly or view it on GitHub
#359 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐐 dimension
 
 
 plotly/tools.py
 
 Outdated
 
 
 There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the table name makes sense here, fwiw 😄
@cldougl Sweet, looking good!! This is going to be awesome!
My biggest concern is the commented out table test. I'd like that to be in place and passing before this rolls on through. Mind giving me a quick poke after some edits are in?
- add validation for `x` and `y` in `annotated_heatmap` - correct/improve docstrings
- uncomment and update table test - add test for `x` and `y` `annotated_heatmap` validation - (also fixed a pep8 mistake from review)
@theengineear thanks for the review!! all updated now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:) thx!
Aw jeez. Throttling issues with testing. Let me throw our test users on to some subscriptions.
💃 after tests 🎏
Aight, re-running your tests.
- `range()` was resulting in an `obj` in python3 where a `list` was needed
- added annotated heatmaps and tables to FigureFactory