-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
Default centering of Heatmaps (and Images) on the x and y values: is this the best choice? #978
Comments
Below I will give an example where the above is implemented in a convenience function. Is this of any use?
Definition of the settings:
Definitions of a matrix and a submatrix of this matrix:
Finally the function call:
Enjoy the resulting plot. It raises a new question: how to set the color range. Note the color coding of the submatrix does not coincide with that of the matrix. Do we need a new attribute for this? Something like the limits attribute of the color bar? |
Sorry, the proper function call is:
|
I first react to your second point. The colorrange specification was simply overlooked from my side. Sorry! I guess I was looking for the attribute limits (used for the colorbar). Variations in syntax (e.g., fontsize or textsize , limits or colorrange) are unfortunate but hard to avoid or eliminate... |
With regard to your first point: consider the heatmap
Let's suppose that this heatmap represents the pixel readings of a camera - say with pixel size of Let's turn to the physical dimensions, obviously Such a shift is unavoidable if one moves from integers to reals. Therefore, my suggestion was to offer the option:
There are several was to implement this
In hindsight the Or did I overlook an existing attribute (e.g., what is the purpose of Thanks for your attention! |
Better: |
if you want to specify the bin edges instead of the bin centers, I guess it's easiest to calculate the centers from the bin edges by taking their midpoints |
I brought up the issue Earlier in this discussion I was playing with the idea of offering the option of both conventions. As I understand it now the new attribute Your feedback is highly appreciated! |
Maybe a bit late to mention this, but a lot of discussion on heatmaps and whatnot has happened in #748. I think the current state is kind of temporary. We added irregular heatmaps and switched to a more reasonable default with centered heatmaps, but lost some performance in the simpler cases and are not as general/tweakable as we want. I think the plan is to add an
|
Thank you for pointing me to #748. I will keep an eye on it. I mentioned In the end most of this is a matter of taste and performance should have preference. |
With regard to this question my reaction on Slack (this weekend) was "good choice" because a heatmap is based on the discrete structure of a matrix. Furthermore, many of us use heatmaps to analyze images of pixel cameras. So for those this centering seems convenient for the same reason (at least for rectangular pixel arrays).
However, at some point one usually has to relate the image to some physical scale (e.g., position on the chip); i.e., we have to move from integers (pixel indices) to reals (physical position on the chip). The latter requires a continues scale
(0.0:xmax)
, wherexmax = xdim * xscale
withxscale
the physical pixel repetition period of the array in thex
direction. Likewise fory
.To have the best of both worlds my suggestion is to add two heatmap attributes,
xscale
andyscale
and implement the plotrange such that:xscale = 0
(i.e., for "no scale") the plotrange defaults to the present implementation(1:xdim)
- "centering on thex
andy
values".xscale = 1
one obtains the range(0.0:xmax)
withxmax = xdim
xscale = xPix
one obtains the range(0.0:xdim*xPix)
, which corresponds to the physical size of the chip in the physical dimension chosen forxPix
(or any other linear-scaling parameter of choice).The text was updated successfully, but these errors were encountered: