Skip to content

Instantly share code, notes, and snippets.

@alexhanna
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexhanna/bc2de9caf51415d69149 to your computer and use it in GitHub Desktop.
Save alexhanna/bc2de9caf51415d69149 to your computer and use it in GitHub Desktop.
p <- ggplot(df.p, aes(x=Margin, y=factor(variable), fill = Class, alpha = value))
p <- p + theme_bw() + geom_tile(color = NA, width = 0.005) + scale_fill_manual(values = wes.palette(2, "Royal1"), labels = c("False Positives", "True Positives"))
p <- p + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
p <- p + theme(axis.text.y = element_text(size = 7)) + ylab("Feature")
ggsave(p, file = "../img/linearsvc_no-fs_top100_fp-v-tp_20140916.png", width = 16, height = 9)
@samarthbhaskar
Copy link

I think you have to pass color and fill in to geom_tile as well

something like geom_tile(aes(color = Class, fill = value))

@samarthbhaskar
Copy link

Hmm -- looks like some people are passing in some "alpha" command -- http://stackoverflow.com/questions/10232525/geom-tile-heatmap-with-different-high-fill-colours-based-on-factor

Also being explicit about fills using scale_fill_manual might be necessary. This will require library(scales) I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment