-
Notifications
You must be signed in to change notification settings - Fork 2k
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
geom_tile()
not square when saving high res map (may be a more fundamental R graphics issue)
#6029
Comments
geom_tile()
not square when saving (may be a more fundamental R graphics issue)geom_tile()
not square when saving his res map (may be a more fundamental R graphics issue)
geom_tile()
not square when saving his res map (may be a more fundamental R graphics issue)geom_tile()
not square when saving high res map (may be a more fundamental R graphics issue)
To quickly clarify one point; On to the main thing; I think the issue you're indicating is that the tiles have different pixel widths and columns look irregular. I've opened the figure in MS Paint, and some columns are 5 pixels wide, whereas others are 6 pixels wide. ggplot2 doesn't really concert itself with how pixels are rendered in raster images. To get pixel-perfect tiles, you probably would have to manually calculate the size of the panels to an exact multiple of your number of tiles. I don't really have experience with this so I wouldn't be able to tell you the calculation on top of my head. |
Hi Teun,
Yes, sorry, should have included that! The tiles are indeed a fixed aspect ratio - the "real world" data effectively follows the same pattern/limits the reprex -
Understood, thanks very much - I didn't think it was a |
Using grid units in this helper will allow you to set the panel size in grid units, but I'm not 100% on top of how to translate grid units to pixels. So if you have a 1000 tiles, each of 5 pixels let's say, you need 5000 pixels. |
Another thing that occured to me is that using
Currently |
just to chime in as a developer of the (2) option. What you run into is basically the inability to divide 10 into 3 equally large integers. It is not possible. As Teun says, you can fix this by increasing the resolution (the error on dividing 100 into 3 equally large integers is much smaller than with 10), but you are much better off saving the plot as raster |
Thank you very much Tom & Teun! We'll explore the options you've outlined above. |
A colleague is encountering an issue saving a large geographical heatmap made using
geom_tile()
; when saving this quite large, high-res plot as a PNG image the squares produced bygeom_tile()
aren't square!reprex:
This produces the below - annotations mine:
We believe this is to do with how R/ggplot2 interpolates between rectangles as when antialiasing is turned off (
snap_rect = FALSE
) the grid is a lot more regular, but has a sort of grid artefact where you can see horizontal/vertical lines - almost like a mosaic.Is there a fix to avoid these non-square tiles when saving without getting the gridlines? As it is a spatial heatmap, it's important for the client to be able to zoom in quite close to each square, and they may question why some are rectangular!
Thanks very much
The text was updated successfully, but these errors were encountered: