Skip to content

Instantly share code, notes, and snippets.

@dill dill/example.R
Created Feb 20, 2016

Embed
What would you like to do?
display R plots in iTerm2
library(ggplot2)
library(emoGG)
source("imgcat.R")
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_emoji(emoji="1f337")
imgcat(print(p))
# 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)
}
@dill

This comment has been minimized.

Copy link
Owner Author

dill commented Feb 20, 2016

Results look like this!
screen shot 2016-02-20 at 15 21 45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.