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

Add single-plot rasterization capability to CairoMakie #1872

Merged
merged 6 commits into from May 5, 2022

Conversation

asinghvi17
Copy link
Member

@asinghvi17 asinghvi17 commented May 3, 2022

Description

Allows the user to tell CairoMakie to rasterize individual Plots in a Scene, by setting plt.rasterize = scale::Int || true.

CairoMakie will rasterize that specific plot to an image with scale^2 pixels per Scene pixel (1 px per scene px if scale=1 or scale=true) and draw it to the main context. The drawing order also preserves the z-order of the scene.

This has the potential to drastically decrease file sizes, which is extremely useful for publication plots and large meshes.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • Added an entry in NEWS.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.

@greimel
Copy link
Contributor

greimel commented May 3, 2022

That's a great feature! This will be handy for plotting maps.

It would be great to have that as a global option as well. Pluto displays pngs by default because to many svgs slow down the browser. Probably this problem could be solved by rasterizing all plots, while keeping axis decorations and text as vector graphics.

@asinghvi17
Copy link
Member Author

I think that this could actually be themable as it is now - if you set rasterize = true in the default themes of Heatmap and Surface, for example, that should "just work". The only potential issue right now is having too many rasterized plots - since each one gets its own image, that would cause a lot of size bloat. Fixing that would be a bit complicated, though.

@SimonDanisch
Copy link
Member

Could you add a test a la: https://github.com/JuliaPlots/Makie.jl/blob/master/CairoMakie/test/svg_tests.jl ?

asinghvi17 and others added 2 commits May 3, 2022 11:38
Co-authored-by: Simon Danisch <sdanisch@protonmail.com>
@asinghvi17
Copy link
Member Author

The CI failure on Makie/Julia 1 does not appear to be related - seems related to mouse click detection.

@asinghvi17 asinghvi17 self-assigned this May 3, 2022
@SimonDanisch SimonDanisch merged commit 1b70e32 into master May 5, 2022
@SimonDanisch SimonDanisch deleted the as/cairomakie_rasterize branch May 5, 2022 17:26
@asinghvi17
Copy link
Member Author

@Datseris this may be useful if you are saving GeoMakie plots to pdf - just pass rasterize = 5 or so as a keyword argument to surface or heatmap!

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

Successfully merging this pull request may close these issues.

Feature request: user-indicated rasterization of huge mesh/heatmap plots in Cairo
3 participants