Skip to content

Instantly share code, notes, and snippets.

@baptiste
baptiste / .block
Last active February 25, 2017 06:42
Testing R to D3 passing of graphical parameters (via JSON)
height: 600
border: no
@baptiste
baptiste / ggguide.r
Last active October 10, 2017 19:19
what if ggplot guides were ggplots
library(ggplot2)
library(grid)
d <- data.frame(x=rnorm(50), y=rnorm(50), f1 = rep(gl(5,5), 2), f2 = gl(2, 25))
p <- ggplot(d, aes(x,y, group=interaction(f1,f2))) +
geom_line(aes(colour=f1, linetype=f2)) +
geom_point(aes(colour=f1, shape=f1))
@baptiste
baptiste / _metadata.yaml
Last active May 7, 2017 04:34
attempting to solve intersect([pacs,keywords,affiliation,fax,...], <this journal's tex idiosyncracy>) with yaml, R, knitr/brew, mustache, and pandoc
title: On physics and chemistry
authors:
- name: Lise Meitner
affiliation: [Kaiser Wilhelm Institute,
University of Berlin,
Manne Siegbahn Institute]
email: [email protected]
- name: Pierre Curie
affiliation: École Normale Supérieure
email: [email protected]
set.seed(123)
dummy <- data.frame(x=runif(10), y=runif(10), f = runif(10))
ggplot(dummy, aes(x,y, fill=f)) +
geom_raster() +
guides(fill=guide_colourbar(label.vjust = 0))+
scale_fill_continuous(lim=c(0,1), expand=c(0,0)) +
labs(fill="gggg") +
theme_grey(24)
require(ggplot2)
library(gridSVG)
library(grid)
plotCoords <- read.csv("http://eborbath.github.io/stackoverflow/PlotCoords.csv")
showCoords <- read.csv("http://eborbath.github.io/stackoverflow/showCoords.csv")
GeomHatch <- ggproto("GeomHatch", GeomPolygon,
<html>
<head>
<title>Title</title>
<script src="//d3js.org/d3.v4.min.js"></script>
<style>
.y.axis path {
fill: none;
stroke: none;
}
@baptiste
baptiste / balloon.R
Last active November 29, 2017 19:53
library(grImport2)
library(grConvert)
library(egg)
convertPicture("noun_3663.svg", "balloon.svg")
balloon <- readPicture("balloon.svg")
d <- data.frame(x=1:9, y=rnorm(9),
data = I(Map(function(c, s) list(c=c,s=s),c=blues9,s=1:9)),
library(jsonlite)
library(ggplot2)
library(ggChernoff)
# https://github.com/Bowserinator/Periodic-Table-JSON
d <- jsonlite::fromJSON('PeriodicTableJSON.json')[["elements"]]
ggplot(d, aes(xpos,10-ypos)) +
geom_chernoff(aes(fill=category, size = phase, smile = density, brow = molar_heat)) +
geom_text(aes(label=symbol), vjust=2.5) +
@baptiste
baptiste / tag.R
Last active January 17, 2018 20:30
library(egg)
l <- list(list(data=mtcars, mapping=aes(mpg, wt)),
geom_path(),
aes(col=wt),
labs(title="Title"),
facet_wrap(~carb))
pl <- Reduce("+", l, init=ggplot(), accumulate = TRUE)
@baptiste
baptiste / .block
Created February 15, 2018 21:20 — forked from ahmohamed/.block
Create a reusable table using d3 and jquery DataTables
license: gpl-3.0