Skip to content

Instantly share code, notes, and snippets.

View gkaramanis's full-sized avatar
😬

Georgios Karamanis gkaramanis

😬
View GitHub Profile
@gkaramanis
gkaramanis / gist:df86ebc15e61d2aa8bd708ccb80cde81
Last active October 3, 2021 08:58
geom_stream vs. geom_line
library(tidyverse)
library(ggstream)
papers <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-09-28/papers.csv')
programs <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-09-28/programs.csv')
paper_programs <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-09-28/paper_programs.csv')
pp <- programs %>%
mutate(program_category = replace_na(program_category, "Technical")) %>%
left_join(paper_programs) %>%
library(ggforce)
library(dplyr)
l <- data.frame(a = c(100, 50, 10)) %>%
mutate(
r = sqrt(a/pi),
x0 = 0,
y0 = r
)
library(ggplot2)
library(cowplot)
p <- ggplot(mtcars, aes(cyl, disp)) +
geom_point() +
labs(title = "But China and India") +
theme(
plot.background = element_rect(fill = "transparent")
)
@gkaramanis
gkaramanis / gist:513f7c738e92d354814d252d76df098c
Created December 24, 2020 11:21
Text in polar coordinations with ggfittext
library(ggfittext)
library(ggplot2)
sensor_data = data.frame(
value = runif(8, min = 0, max = 120),
label = paste0("sensor", 1:8)
)
ggplot(sensor_data) +
geom_col(aes(x = label, y = value)) +
--==============================
-- Send Keynote Text to Desktop Markdown File
-- Writted By: Richard Dooling https://github.com/RichardDooling/
-- Based on
-- Send Keynote Presenter Notes to Evernote
-- Version 1.0.1
-- Written By: Ben Waldie <ben@automatedworkflows.com>
-- http://www.automatedworkflows.com
-- Version 1.0.0 - Initial release
library(ggplot2)
library(tidyr)
library(viridis)
df <- data.frame(x = 1:10, y = 1:10) %>% expand(x, y) %>% mutate(n = as.integer(runif(min = 0, max = 26, n = 100)))
pal <- c(viridis(n = 23), "black", "purple", "pink")
ggplot(df, aes(x, y, fill = factor(n))) +
geom_tile() +
@gkaramanis
gkaramanis / axis-bg.R
Last active February 22, 2020 15:07
Add "background" to axis title
library(ggplot2)
library(grid)
myGrob <- grobTree(rectGrob(gp = gpar(fill = "purple", alpha = 0.5)))
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) +
geom_point() +
annotation_custom(myGrob, xmin = -10, xmax = -1, ymin = -10, ymax = Inf) + # x axis
annotation_custom(myGrob, xmin = -10, xmax = Inf, ymin = -10, ymax = -1) + # y axis
coord_cartesian(xlim = c(0, 10), ylim = c(0, 10), clip = "off") +
library(ggplot2)
ggplot(data = data.frame(x = c(-4, 6)), aes(x)) +
stat_function(fun = dnorm, n = 101, args = list(mean = 0, sd = 1), geom = "area", fill = "#F5BB87", alpha = 0.9) +
stat_function(fun = dnorm, n = 101, args = list(mean = 2.7, sd = 1), geom = "area", fill = "#BBD4EB", alpha = 0.9) +
coord_fixed(xlim = c(-5, 7), ratio = 8, clip = "off") +
annotate("segment", x = -3.9, y = 0, xend = 6, yend = 0, color = "grey60", size = 1.3) +
annotate("segment", x = -3.5, y = -0.04, xend = -3.5, yend = 0.42, color = "grey60", size = 1.3) +
annotate("text", x = 0, y = 0.18, label = "what people\nactually do\nin R", family = "Arial Bold", color = "white", size = 5.2) +
annotate("text", x = 2.75, y = 0.18, label = "what people\nassume others\ndo in R", family = "Arial Bold", color = "white", size = 5.2) +
@gkaramanis
gkaramanis / leaf.R
Last active August 14, 2019 13:00
Draw a leaf with closed b-spline shape in ggforce
library(ggforce)
library(ggplot2)
leaf <- data.frame(
x = c(1.6, 1.5, 1.8, 1.5, 1.6, 1.3),
y = c(2, 2, 1.5, 1, 1, 1.5)
)
ggplot(leaf, aes(x, y)) +
geom_polygon(fill = NA, colour = 'grey') +
@gkaramanis
gkaramanis / Mailblink.scpt
Last active December 11, 2015 21:39
Mailblink