-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Help implementing datashader-like functionality #443
Comments
You can get the pixel-area of the scene by |
While this is somewhat true, I'd recommend:
|
Thanks for your replies. Maybe take a look at the examples at the bottom of https://examples.pyviz.org/heat_and_trees/Heat_and_Trees.html#heat-and-trees-gallery-heat-and-trees to see what I'm aiming for. That is, I still want to have axes, and maybe those axes will contain points and lines and things like any other plot, but I also want to be able to draw an image in that plot, where the image is produced at exactly the right size (in pixels) for the plot, hence I need to know the limits of the axes and the size of the axes in pixels. I believe |
Hm I guess, there are different ways of doing this... Do you want to use MakieLayout as well? And do you want to zoom in and then update the image that is displayed? Is it very important to map 1 image pixel to screen pixels, or would it just be nice? |
I'm not familiar with MakieLayout, but from the quick look I've just had, yes! The 1-1 correspondence between pixels is important: basically the image is a 2D histogram, where each pixel represents a bin, and so we get very fine-grained visualization. And yes, I want to be able to zoom in on regions of the image and have it be recomputed. |
@jkrumbiegel, this could be kind of easy in makielayouts, no? |
yeah this is basically all you need: using Makie
using MakieLayout
scene, layout = layoutscene()
ax = layout[1, 1] = LAxis(scene)
function datashader(limits, pixelarea)
# return your heatmap data
# here, I just calculate a sine field as a demo
xpixels, ypixels = widths(pixelarea)
xmin, ymin = minimum(limits)
xmax, ymax = maximum(limits)
[cos(x) * sin(y) for x in LinRange(xmin, xmax, xpixels),
y in LinRange(ymin, ymax, ypixels)]
end
xrange = lift(x -> minimum(x)[1] .. maximum(x)[1], ax.limits)
yrange = lift(x -> minimum(x)[2] .. maximum(x)[2], ax.limits)
pixels = lift(datashader, ax.limits, ax.scene.px_area)
heatmap!(ax, xrange, yrange, pixels,
xautolimits = false, yautolimits = false)
Update: I see what the problem is, the xrange and yrange cut their maximum off if they are written with colon notation, because the step size is implicitly 1. I've edited the example to use .. interval notation, this works perfectly. |
Just seen this, that's brilliant, works like a charm. Thanks for your help! |
This is incorporated into Makie with #2883 with an experimental datashader functionality. |
I'd quite like to incorporate some datashader-like functionality into Makie. Basically, I need to be able to do the following, but it's not clear that it's currently possible in Makie?
Grateful if you could enlighten me on whether this is currently possible.
The text was updated successfully, but these errors were encountered: