Add rasterization support for simple heatmap annotations#1260
Open
brandonlukas wants to merge 2 commits into
Open
Add rasterization support for simple heatmap annotations#1260brandonlukas wants to merge 2 commits into
brandonlukas wants to merge 2 commits into
Conversation
Previously only the heatmap body (matrix) supported rasterization via use_raster. This adds the same capability to simple annotations (vector/matrix values drawn as colored cells via anno_simple), reducing PDF/SVG file sizes for large annotations. Changes: - Add rasterize_in_viewport() helper to utils.R, encapsulating the temp-device rasterization pattern from draw_heatmap_body() - Add raster_param slot to SingleAnnotation class with use_raster, raster_device, raster_quality, and related parameters - Wrap annotation drawing in SingleAnnotation draw() with rasterization when use_raster=TRUE (annotation names remain vector graphics) - Pass raster params through HeatmapAnnotation constructor to each SingleAnnotation - Add annotation_use_raster global option to ht_opt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When raster_quality > 1, the temp raster device grew in pixels but kept the default res=72, making its physical size (inches) grow proportionally. AnnotationFunction::draw() pushes a viewport with absolute units (e.g. unit(5, "mm")), which then only filled 1/raster_quality of the enlarged device, causing the annotation to appear vertically shrunken. Fix by scaling res with raster_quality so the device's physical size stays constant regardless of quality level. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously only the heatmap body (matrix) supported rasterization via use_raster. This adds the same capability to simple annotations (vector/matrix values drawn as colored cells via anno_simple), reducing PDF/SVG file sizes for large annotations.
Changes: