Created
February 20, 2016 20:23
-
-
Save dill/9fca5140c44acf6051a9 to your computer and use it in GitHub Desktop.
display R plots in iTerm2
This file contains 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(emoGG) | |
source("imgcat.R") | |
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_emoji(emoji="1f337") | |
imgcat(print(p)) |
This file contains 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
# display your plots inline using imgcat witchcraft | |
# download imgcat from https://raw.githubusercontent.com/gnachman/iTerm2/master/tests/imgcat | |
# you need the beta version of iTerm2 to get this to work on Mac | |
# untested elsewhere | |
# David Lawrence Miller GPL 2016 | |
imgcat <- function(plot_command){ | |
fn <- tempfile(pattern = "file", tmpdir = tempdir(), fileext = "") | |
png(fn) | |
eval(quote(plot_command)) | |
dev.off() | |
system2("imgcat", fn) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Results look like this!