Makie.image plots a set of pixels efficiently, assuming that the image starts at the origin (0,0) and that the pixels are of size 1x1.
We tried to apply Makie.scale! and Makie.translate! to the result of Makie.image to correct the origin and spacing of the plot, but these operations move the plot to outside the visible area, i.e., the axis is not automatically adjusted to fit all objects in the scene.
Is there a function to automatically adjust the axis? Can it be called from inside a Makie recipe?
Alternatively, can we call Makie.image with custom origin and fixed spacing per dimension?
try image(xmin .. xmax, ymin .. ymax, data). I think the translate route is more efficient when updating, though, because it doesn’t affect the conversion pipeline.
using Makie
using GLMakie
@recipe(ScaledImage, img, x, y) do scene
Attributes()
end
function Makie.plot!(plot::ScaledImage)
image!(plot, plot.img, interpolate=false)
scale!(plot, plot.x[], plot.y[])
# how to adjust the axis after scaling the plot?
end
img = rand(1:9, 10, 10)
scaledimage(img, 2.5, 1.5)
In this case, how can we adjust the axis within a recipe?
This is behavior of Makie that is not quite correct yet, I think the model matrix should be included in the limit calculations. If it was, you wouldn’t have to do anything special in the recipe.