-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
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 |
|
||
@staticmethod | ||
def create_table(text, colorscale=[[0, '#66b2ff'], [.5, '#e6e6e6'], | ||
[1, '#ffffff']], fontcolor=['#000000'], |
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 :):))
>>> 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() |
ok @chriddyp @theengineear sorry for that false alarm earlier- it's ready now! |
|
- remove margins from tables
I like the default table colors, but @jackparmer or @delekru might have an opinion |
yep np! |
Nice! +1 on Derek's colors. Looks like Fornightly Thoughts On Wed, Nov 25, 2015 at 2:34 PM, derek lu notifications@github.com wrote:
|
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 On Wed, Nov 25, 2015 at 2:41 PM, Chelsea notifications@github.com wrote:
|
@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 On Wed, Nov 25, 2015 at 3:03 PM, Chelsea notifications@github.com wrote:
|
|
||
def test_unequal_z_text_size(self): | ||
|
||
# check: PlotlyError if z and text are not the same dimmensions |
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
['Canada', 2010, 34000000]] | ||
|
||
table=FF.create_table(text) | ||
py.iplot(table) |
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 |
hex_total_length = len(value) | ||
rgb_section_length = hex_total_length // 3 | ||
return tuple(int(value[i:i + rgb_section_length], 16) | ||
for i in range(0, hex_total_length, rgb_section_length)) |
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