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

Annotated Heatmap with custom color scale raises ValueError #1122

Closed
andy-lz opened this issue Aug 20, 2018 · 3 comments
Closed

Annotated Heatmap with custom color scale raises ValueError #1122

andy-lz opened this issue Aug 20, 2018 · 3 comments
Labels
bug something broken
Milestone

Comments

@andy-lz
Copy link

andy-lz commented Aug 20, 2018

Creating an annotated heatmap with figure factory using a custom color scale (as seen below) leads to a ValueError: "map object not subscriptable."

import plotly.figure_factory as ff

data_test2 = ff.create_annotated_heatmap(z=z, x=x, y=y, colorscale=[[0.0, 'rgb(250,0,0)'], [0.5, 'rgb(250,250,250)'], [1.0, 'rgb(0,0,0)']], annotation_text=df_str, showscale=True)

I fixed this by explicitly defining the map objects for min_col and max_col in _AnnotatedHeatMap.get_text_color() as lists.

@jonmmease
Copy link
Contributor

jonmmease commented Aug 22, 2018

Thanks for the report @andy-lz . Could you add a quick example that results in this error?

Basically, just include some simple definitions of x, y, z, etc. so that someone can copy and paste it into a notebook cell and see the error.

Thanks!

@jonmmease jonmmease added the bug something broken label Aug 22, 2018
@andy-lz
Copy link
Author

andy-lz commented Aug 27, 2018

Used a modified example from plotly documentation.

import plotly.plotly as py
import plotly.figure_factory as ff

z = [[.1, .3, .5],  
     [1.0, .8, .6],
     [.6, .4, .2]]

x = ['Team A', 'Team B', 'Team C']
y = ['Game Three', 'Game Two', 'Game One']

z_text = [['Win', 'Lose', 'Win'],  
          ['Lose', 'Lose', 'Win'],
          ['Win', 'Win', 'Lose']]

fig = ff.create_annotated_heatmap(z, x=x, y=y, annotation_text=z_text, colorscale=[[0.0, 'rgb(250,0,0)'], [0.5, 'rgb(250,250,250)'], [1.0, 'rgb(0,0,0)']])

@jonmmease
Copy link
Contributor

Done in #1151

@jonmmease jonmmease added this to the v3.2.0 milestone Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

2 participants