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 flips rows/columns #80

Open
ssfrr opened this issue Oct 4, 2016 · 3 comments
Open

heatmap flips rows/columns #80

ssfrr opened this issue Oct 4, 2016 · 3 comments

Comments

@ssfrr
Copy link
Contributor

ssfrr commented Oct 4, 2016

The heatmap plot type is useful for visualizing a matrix, but the cells are all transposed relative to how matrices are represented at the REPL. Additionally it is flipped so that index (1, 1) is at the bottom-left.

For Example:

plot(heatmap(z=reshape(1:12, 3, 4)))

Shows this:
screen shot 2016-10-04 at 4 49 36 pm

The plotly.js docs don't seem to specify whether they expect row-major or column-major 2D arrays, but empirically they treat them as row-major. JSON.jl renders 2D matrices as column-major. It's always a tough call to decide when it's worth adding extra processing between PlotlyJS.jl and plotly.js, but in this case the behavior seems to be something of an implementation detail that it would be OK to change.

I'm a little more torn on the origin location (bottom-left vs. top-left) as that's a user-visible change that would make it behave differently than plotly.js.

@sglyon
Copy link
Member

sglyon commented Oct 5, 2016

Thanks for opening this.

I think it probably makes sense to transpose the z matrix for the heat map. That being said, I don't know that PlotlyJS currently has the machinery in place to do this. We'll have to think about what point between creating a trace and displaying a plot is the right place for this type of logic.

I don't think we should try to change the location of the origin.

@tbreloff
Copy link
Member

tbreloff commented Oct 5, 2016

Fyi this has been discussed at length and resolved in Plots:
https://github.com/tbreloff/Plots.jl/issues?utf8=✓&q=is%3Aissue%20heatmap%20transpose
https://github.com/tbreloff/Plots.jl/issues?utf8=%E2%9C%93&q=is%3Aissue%20heatmap%20transpose

You'll need to add 'yflip=true' to also put the origin in the upper-left
corner (not the most common use of heatmap for most people).

On Wednesday, October 5, 2016, Spencer Lyon [email protected]
wrote:

Thanks for opening this.

I think it probably makes sense to transpose the z matrix for the heat
map. That being said, I don't know that PlotlyJS currently has the
machinery in place to do this. We'll have to think about what point between
creating a trace and displaying a plot is the right place for this type of
logic.

I don't think we should try to change the location of the origin.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#80 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA492iqxBf_QfdcmRROLDY0_jcNFr6o-ks5qw4jHgaJpZM4KOJu5
.

@sglyon
Copy link
Member

sglyon commented Oct 5, 2016

Thanks @tbreloff -- that's very helpful.

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

3 participants