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

Heatmap should look up category position when building brick data #1117

Closed
colinfang opened this issue Nov 7, 2016 · 5 comments · Fixed by #3827
Closed

Heatmap should look up category position when building brick data #1117

colinfang opened this issue Nov 7, 2016 · 5 comments · Fixed by #3827
Assignees
Labels
bug something broken

Comments

@colinfang
Copy link

colinfang commented Nov 7, 2016

The 2nd plot should start at Team B, instead of Team A.

fig = make_subplots(rows=2, cols=1, shared_yaxes=True, shared_xaxes=True)

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']

fig.append_trace(go.Heatmap(z=z, x=x, y=y), 1, 1)

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

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

fig.append_trace(go.Heatmap(z=z, x=x, y=y), 2, 1)
iplot(fig)
fig.data

[{'type': 'heatmap',
  'x': ['Team A', 'Team B', 'Team C'],
  'xaxis': 'x1',
  'y': ['Game Three', 'Game Two', 'Game One'],
  'z': [[.1, .3, .5],  
     [1.0, .8, .6],
     [.6, .4, .2]],
  'yaxis': 'y1'},
 {'type': 'heatmap',
  'x': ['Team B', 'Team C'],
  'xaxis': 'x1',
  'y': ['Game Three', 'Game Two', 'Game One'],
  'z': [[.3, .5],  
     [.8, .6],
     [.4, .2]],
  'yaxis': 'y2'}]

fig.layout

{'xaxis1': {'anchor': 'y2', 'domain': [0.0, 1.0]},
 'yaxis1': {'anchor': 'free', 'domain': [0.575, 1.0], 'position': 0.0},
 'yaxis2': {'anchor': 'x1', 'domain': [0.0, 0.425]}}

newplot 6

https://codepen.io/anon/pen/qqdqWq

@etpinard
Copy link
Contributor

etpinard commented Nov 7, 2016

replacing

x = ['Team B', 'Team C']

with

x = [None, 'Team B', 'Team C']

should do the trick.

@colinfang
Copy link
Author

It doesn't work in JS.

I hope this is a bug instead of expected behaviour, as in Bar plot the shared axis do align on the name.

@etpinard
Copy link
Contributor

etpinard commented Nov 7, 2016

Ha I see. You're expecting each z column to shift in accordance with x.

I believe this is the result of the same underlying issue as #1097

Here's a way to work around the problem: https://codepen.io/etpinard/pen/QGbGNP

@etpinard etpinard added the bug something broken label Nov 7, 2016
@etpinard etpinard changed the title Heatmap subplot with share_xaxes align using index instead of name. Heatmap should look up category position when building brick data Nov 7, 2016
@etpinard
Copy link
Contributor

etpinard commented Nov 7, 2016

@colinfang thanks for posting 🍻

Next time, to make our lives a little easier, please don't make references to the plotly.py API (or any other API library) in this repo. It can make things a little confusing on how to approach the issue. A reproducible codepen suffices.

@etpinard etpinard self-assigned this Nov 16, 2016
@etpinard
Copy link
Contributor

Update: solving this problem and #1097 in general is a little harder than I thought.

At the moment, the heatmap plotting routine fails when x and y are unsorted (even when x and y are numerical - see http://codepen.io/etpinard/pen/RoKGpj)

So, I think we'll need to order x and y and rearrange z in the calc step. From heatmap/plot.js this issue isn't news.

    // TODO: if there are multiple overlapping categorical heatmaps,
    // or if we allow category sorting, then the categories may not be
    // sequential... may need to reorder and/or expand z

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

Successfully merging a pull request may close this issue.

3 participants