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

option to flip heatmap #46

Closed
ssfrr opened this issue Jan 11, 2018 · 13 comments
Closed

option to flip heatmap #46

ssfrr opened this issue Jan 11, 2018 · 13 comments

Comments

@ssfrr
Copy link
Contributor

ssfrr commented Jan 11, 2018

currently heatmap puts cell (1,1) in the top-left corner. This is often what you want (like when visualizing an image), but other times you want it on the bottom-left (e.g. in an audio spectrogram).

for reference PyPlot's imshow function takes the origin="upper" or origin="lower" options.

@mkborregaard
Copy link
Contributor

The Plots syntax is yflip = true

@ssfrr
Copy link
Contributor Author

ssfrr commented Jan 11, 2018

I find that less clear - you have to know what the default is to understand what yflip will do

@mkborregaard
Copy link
Contributor

mkborregaard commented Jan 11, 2018

It's also a lot more general - it's not restricted to heatmaps, which is just another seriestype for plot, rather than some specific plotting function with bespoke arguments to learn. The y axis has the lowest value in the bottom on all plots, so there's nothing to remember. If you want the y axis to have the lowest value on top, you use yflip = true. It's also not restricted to the y axis, you can xflip and zflip as well (they of course also by default have the lowest values at the origin).

That's the key point of Plots and I believe a central component of its success: generality.

(That said it would be easy to have the flip keywords accept :origin_top and :origin_bottom arguments as well for those who'd like that - accepting both Bool and Symbol is a classic strategy in Plots for clarity)

@ssfrr
Copy link
Contributor Author

ssfrr commented Jan 11, 2018

Yeah, if the convention is that the origin is in the lower-left for everything than I can see how yflip is good and consistent. In that case the default for heatmap should be flipped from what it is now (the origin is currently in the top-left), and `yflip=true would flip it back, right?

@mkborregaard
Copy link
Contributor

Yes 👍

@SimonDanisch
Copy link
Member

I'm planning to have each visual be accompanied by a rich transformation attribute - which will support padding, placement, flipping and maybe even arbitrary transformation functions, if I figure opengl transpilation out fast enough.
This will get implemented for all plotting types and it will be possible to inherit those from the parent scene (so that you can transform the whole scene).

@mkborregaard
Copy link
Contributor

That sounds awesome.

@asinghvi17
Copy link
Member

scale! should do this.

SimonDanisch added a commit that referenced this issue Jun 3, 2021
@xaviergonzalez
Copy link

Wait so how do we actually flip the y-axis for a heatmap in Makie?

@jkrumbiegel
Copy link
Member

ax.yreversed = true

@xaviergonzalez
Copy link

ax.yreversed = true

But what if I'm not using an ax atttribute, i.e. I'm just doing something like

CairoMakie.heatmap(mat, yflip=true)

This code produces the heatmap, just not with the y-axis flipped.

@asinghvi17
Copy link
Member

You would have to do CairoMakie.heatmap(mat, axis = (yflip=true,)).

@jkrumbiegel
Copy link
Member

It's yreversed if I'm not wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants