Last active
December 12, 2020 02:06
-
-
Save Athospd/3c6c6d03a1c6ba04a95c617a48c7c182 to your computer and use it in GitHub Desktop.
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
| library(tidyverse) | |
| gg_cartesian_grid <- function(width, height) { | |
| data.frame( | |
| x = width*c(-1, 1), | |
| y = height*c(-1, 1) | |
| ) %>% | |
| ggplot(aes(x, y)) + | |
| geom_hline(yintercept = 0, colour = "white") + | |
| geom_vline(xintercept = 0, colour = "white") + | |
| scale_x_continuous(limits = width/2*c(-1, 1), n.breaks = width/100) + | |
| scale_y_continuous(limits = height/2*c(-1, 1), n.breaks = height/100) + | |
| theme_minimal() + | |
| theme(axis.title = element_blank(), | |
| panel.border = element_rect(colour = "white"), | |
| plot.background = element_rect(fill = "transparent", color = NA), # bg of the plot | |
| panel.background = element_rect(fill = "transparent"), | |
| axis.ticks = element_line(colour = "white"), | |
| axis.text = element_text(colour = "white"), | |
| panel.grid = element_line(colour = "white"), | |
| legend.background = element_rect(fill = "transparent"), # get rid of legend bg | |
| legend.box.background = element_rect(fill = "transparent"), | |
| rect = element_blank() | |
| ) + | |
| coord_equal(ratio = 1) | |
| } | |
| gg_cartesian_grid(1920*1.5, 1080*1.5) | |
| ggsave("gggrid.png", width = 6.49*1.5, height = 4.43*1.5, bg = "transparent") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment