From 72b6702a2dbc39083df191852dae68b60e0a3637 Mon Sep 17 00:00:00 2001
From: Holger Brandl <brandl@mpi-cbg.de>
Date: Thu, 18 Dec 2014 17:06:53 +0100
Subject: [PATCH] added palette function for color scale management

---
 R/ggplot_commons.R | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/R/ggplot_commons.R b/R/ggplot_commons.R
index 4b50907..79610fc 100644
--- a/R/ggplot_commons.R
+++ b/R/ggplot_commons.R
@@ -152,3 +152,12 @@ makePcaPlot <- function(x = getData(), group = NA, items=rownames(x), title = ""
 plotPDF <- function(filename, expr){ pdf(paste0(filename, ".pdf")); expr; dev.off(); }
 #plotPDF("test", plot(1:10))
 
+
+## create a custom color palette for a fixed set of values
+## scale_fill_manual(values = create_palette(unique(csWithTopoT1$t1_type)), drop = FALSE)
+create_palette <- function(x, pal = 'Set1'){
+  ux <- sort(unique(x))
+  n <-length(ux)
+  setNames(brewer.pal(name = pal, n = n)[1:n], ux)
+}
+
-- 
GitLab