Skip to content

Instantly share code, notes, and snippets.

@srvanderplas
Last active January 4, 2016 03:49
Show Gist options
  • Save srvanderplas/8564397 to your computer and use it in GitHub Desktop.
Save srvanderplas/8564397 to your computer and use it in GitHub Desktop.
Problem with theme() settings and ggplot2 in Rstudio
library(nullabor)
library(ggplot2)
library(plyr)
theme_lineup <- function(base_size = 12, base_family = ""){
theme_bw(base_size = base_size, base_family = base_family) %+replace%
theme(legend.position="none",
axis.text=element_blank(),
axis.title=element_blank(),
axis.ticks=element_blank())}
n0 <- 3
n1 <- 10
n2 <- 30
u <- rnorm(n0+n1+n2)
v <- c(rnorm(n0)-3, rnorm(n1), rnorm(n2)+3)
x <- u+v
y <- u-v
color <- factor(rep(c("A","A","B"), c(n0,n1,n2)))
dframe <- data.frame(x, y, color)
# Slope alone
pos.x <- sample(1:20, 1)
lineupdata <- lineup(null_permute("y"), dframe, pos=pos.x)
ggplot(data=lineupdata) +
geom_point(aes(x=x, y=y)) +
facet_wrap(~.sample) +
theme_lineup()
# Problem: plot does not display in Rstudio, but plot code works correctly in base R.
# Have reproduced this in version 0.98.308 on a Mac and 0.98.484 on Linux.
# I have had the same problem with axis.ticks() in the past as well.
# Output of sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plyr_1.8 ggplot2_0.9.3.1 nullabor_0.2.1
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 dichromat_2.0-0 digest_0.6.4 grid_3.0.2 gtable_0.1.2 labeling_0.2 MASS_7.3-29
[8] munsell_0.4.2 proto_0.3-10 RColorBrewer_1.0-5 reshape2_1.2.2 scales_0.2.3 stringr_0.6.2 tools_3.0.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment