Skip to content

Instantly share code, notes, and snippets.

@gufodotto
Created July 8, 2012 08:02
Show Gist options
  • Save gufodotto/3069892 to your computer and use it in GitHub Desktop.
Save gufodotto/3069892 to your computer and use it in GitHub Desktop.
grid.newpage()
# create a tile matrix with 0 and 1 depending on which parameter is being fitted.
cl1<-ggplot(Coll_m) + geom_tile(aes(X1, X2, fill=value), , col='white') + scale_fill_gradient(low='white', high='black', limits=c(0, 1))
# fill the same matrix with tiles of two different colors
cl1<-cl1 + geom_text(aes(X1, X2, label=value, col=value)) + scale_color_gradient(low='black', high='white', limits=c(0, 1))
cl1<-cl1 + opts(title="Parameters' N-ways Identifiability", axis.title.x = theme_blank(), axis.title.y = theme_blank(), axis.text.y = theme_text(colour = NA), axis.ticks = theme_segment(colour = NA), axis.text.x = theme_text(size = 12), legend.position='none')
# now, on the right side, fill colors depending on the collinearity values
cl2<-ggplot(Coll_f) + geom_tile(aes(X1, X2, fill=flag), col='white') + scale_fill_manual(values=c('green','red'))
# finally print clipped collinearity values
cl2<-cl2 + geom_text(data=Coll_f, aes(X1, X2, label=label), col='black') + theme_bw() + guides(fill=guide_legend(title=NULL)) +
# and all options to make the graph look right
opts(title="", axis.title.x = theme_blank(), axis.title.y = theme_blank(), axis.text.y = theme_text(colour = NA), axis.ticks = theme_segment(colour = NA), axis.text.x = theme_text(size = 12), legend.position='none')
pushViewport(viewport(layout = grid.layout(6, 7)));
print(cl1, vp=vplayout(1:6,1:5))
print(cl2, vp=vplayout(1:6,6:7))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment