Created
October 29, 2020 22:15
-
-
Save djnavarro/1cf4d96777f7b50f3069e86ed36e041c 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(ggplot2) | |
library(dplyr) | |
library(here) | |
# create data structure | |
pxl <- 5000 | |
dat <- expand.grid( | |
k = seq(0, 1, by=.001), | |
n = seq(44, 55, by=.01) | |
) | |
dat <- dat %>% | |
mutate(z = (k + 2^n - 2^n - k)) %>% | |
mutate(f = sign(z) * abs(z)^.25) %>% | |
arrange(k, n) | |
# set zeros to NA for data visualisation purposes | |
dat$f[dat$f == 0] <- NA | |
# create plot object | |
pic <- ggplot(dat, aes(x = k, y = n, fill = f)) + | |
geom_raster(show.legend = FALSE) + | |
theme_void() + | |
scale_fill_viridis_c(option = "magma", na.value = "white") + | |
scale_x_continuous(expand = c(0, 0)) + | |
scale_y_continuous(expand = c(0, 0)) + | |
NULL | |
# draw plot | |
ggsave( | |
filename = here("image", "floating_point_09.png"), | |
plot = pic, | |
height = pxl/300, | |
width = pxl/300, | |
dpi = 300 | |
) | |
Author
djnavarro
commented
Oct 29, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment