-
-
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
Support for rendering image markers with CairoMakie #2080
Support for rendering image markers with CairoMakie #2080
Conversation
Tests are failing because of a failure in the conversion pipeline for the markers. I retraced it to this PR #1981 which introduced the # an array of markers is converted to string by itself, which is inconvenient for the iteration logic
_marker_convert(markers::AbstractArray) = map(m -> convert_attribute(m, key"marker"(), key"scatter"()), markers)
_marker_convert(marker) = convert_attribute(marker, key"marker"(), key"scatter"()) The issue is that when scattering with image markers you pass a marker of type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks! Couple of minor changes requested.
Oops...I guess this breaks WGLMakie. Maybe we could exclude this test from there? |
Can't we fix this right now? Although I would not know how 😅 |
Is this really just for PDF, or for CairoMakie? Looks to me like the latter, no? |
Aeeehhh, could be 😅. I only tested with PDFs. I guess @asinghvi17's 👍 to your answer indicates that it also works for Honestly, I am don't know yet which parts of Makie are responsible for saving scenes to files? And what file formats it can handle? |
Basically, you can think of it this way - Makie specifies the points to render, and the backend packages actually render them. CairoMakie works with PNG and vector types (SVG, EPS, PDF). [W]GLMakie works only with bitmap/raster types (fundamentally PNG) and conversions to jpg, bmp, tiff, etc. For example, a complex recipe will be degraded to atomic plots (lines, scatter, heatmap/image, surface, mesh, meshscatter, volume) by Makie. The backend's basic task is to render these atomic plots in the correct positions. Of course, you can then hook into higher level recipes to render those directly if you want, as CairoMakie does with poly. GLMakie renders only atomic level plots to OpenGL, WGLMakie renders them to browser. At one point we had a GRMakie which was trying to render Makie plots with GR, but it lost momentum and the packages weren't really that compatible. |
GLMakie CI actually passes, but since this post is from an external PR I guess the bot can't comment that there is a missing refimage. Otherwise this is good to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there are some bugs here - shouldn't be too difficult to fix though.
Left is reference image, right is recorded image - this is from the Image scatter different sizes
example.
The scale of the bottom marker looks weird and the top marker seems (a) misaligned and (b) somehow more compressed?
More detail on the top marker weirdness
I pushed a fix for the wrong scaling, at least now the Makie logo looks ok (the problem were swapped dimensions due to the However, the logo and the doggy now both appear smaller than in the ref image (as you already noted above). |
Could you try rendering with different |
I already tried with different scaling. E.g. adding an artificial factor of 3/2 gives roughly the same size as the ref image.
Perhaps it is the difference between using FileIO
using CairoMakie
CairoMakie.activate!()
using Makie
img = Makie.logo()
img2 = load(Makie.assetpath("doge.png"))
images = [img, img2]
# markersize = map(img-> Vec2f(reverse(size(img) ./ 10)), images)
markersize = [ ( 1.0,0.5 ), ( 1.0,1.0 ) ]
s = scatter(1:2, [0.75,2], marker = images, markersize=markersize, axis=(limits=(0.5
markerspace=:data)
save("scatter.pdf", s) |
Sorry, did not notice that there is an actual |
I opened an issue for the colored edges problem since it also appears when saving it as This PR should now be good to go. |
Thank you all! :) |
Might be that I forgot to check the |
Description
Overload
CairoMakie.draw_marker
forMatrix{<:Colorant}
types which allows to render images as markers.Type of change
Checklist