Commit af7403e9 authored by Maciej Dobrzynski's avatar Maciej Dobrzynski Committed by GitHub

Merge pull request #6 from majpark21/master

Changed default palette to colorblind friendly
parents 7891ea8c ff69113e
......@@ -274,9 +274,17 @@ modDistPlot = function(input, output, session,
else
NA
)
# If more than max.col groups, cycle through the palette ("Color Blind" can return 10 colors at maximum)
loc.pal = "Color Blind"
max.col = attr(ggthemes::tableau_color_pal(loc.pal), "max_n")
loc.col = ggthemes::tableau_color_pal(loc.pal)(n = max.col)
ngroups = uniqueN(loc.dt[, get(in.cols$group)]) - 1
loc.col = rep(loc.col, (ngroups %/% max.col) + 1)
loc.col = loc.col[1:(ngroups+1)]
p.out = p.out +
scale_fill_discrete(name = in.labels$legend) +
xlab(in.labels$x) +
ylab(in.labels$y) +
LOCggplotTheme(in.font.base = PLOTFONTBASE,
......@@ -286,7 +294,8 @@ modDistPlot = function(input, output, session,
in.font.legend = PLOTFONTLEGEND) +
theme(legend.position = input$selPlotBoxLegendPos,
axis.text.x = LOCrotatedAxisElementText(as.numeric(input$rBAxisLabelsRotate),
size = PLOTFONTAXISTEXT))
size = PLOTFONTAXISTEXT)) +
scale_fill_manual(name = in.labels$legend, values = loc.col)
return(p.out)
......
......@@ -318,6 +318,9 @@ clustValid <- function(input, output, session, in.dataWide) {
if (sum(is.na(loc.dm)) > 0)
return(NULL)
loc.pal = ifelse(returnNclust() <= 10, "Color Blind", "Tableau 20")
loc.col = ggthemes::tableau_color_pal(loc.pal)(n = returnNclust())
loc.p = factoextra::fviz_cluster(loc.part,
data = loc.dm,
geom = "point",
......@@ -328,7 +331,9 @@ clustValid <- function(input, output, session, in.dataWide) {
in.font.axis.text = PLOTFONTAXISTEXT,
in.font.axis.title = PLOTFONTAXISTITLE,
in.font.strip = PLOTFONTFACETSTRIP,
in.font.legend = PLOTFONTLEGEND)
in.font.legend = PLOTFONTLEGEND) +
scale_fill_manual(values = loc.col) +
scale_colour_manual(values = loc.col)
# Retrieve association of cluster and colours and use it for dendrogram for color matching between dend, silhouette and PCA plot
......@@ -396,6 +401,9 @@ clustValid <- function(input, output, session, in.dataWide) {
need(!is.null(loc.part), "Nothing to plot. Load data first!")
)
loc.pal = ifelse(returnNclust() <= 10, "Color Blind", "Tableau 20")
loc.col = ggthemes::tableau_color_pal(loc.pal)(n = returnNclust())
loc.p = factoextra::fviz_silhouette(loc.part,
print.summary = FALSE,
main = "Silhouette") +
......@@ -405,7 +413,9 @@ clustValid <- function(input, output, session, in.dataWide) {
in.font.axis.title = PLOTFONTAXISTITLE,
in.font.strip = PLOTFONTFACETSTRIP,
in.font.legend = PLOTFONTLEGEND) +
theme(axis.text.x = element_blank())
theme(axis.text.x = element_blank()) +
scale_fill_manual(values = loc.col) +
scale_colour_manual(values = loc.col)
return(loc.p)
}
......
......@@ -350,6 +350,14 @@ modTrajRibbonPlot = function(input, output, session,
loc.ylim.arg = c(input$inSetYboundsLow, input$inSetYboundsHigh)
}
# If more than max.col groups, cycle through the palette ("Color Blind" can return 10 colors at maximum)
loc.pal = "Color Blind"
max.col = attr(ggthemes::tableau_color_pal(loc.pal), "max_n")
loc.col = ggthemes::tableau_color_pal(loc.pal)(n = max.col)
ngroups = uniqueN(loc.dt.aggr[, ..in.facet]) - 1
loc.col = rep(loc.col, (ngroups %/% max.col) + 1)
loc.col = loc.col[1:(ngroups+1)]
p.out = LOCplotTrajRibbon(dt.arg = loc.dt.aggr,
x.arg = COLRT,
y.arg = 'Mean',
......@@ -368,7 +376,8 @@ modTrajRibbonPlot = function(input, output, session,
in.font.axis.title = PLOTFONTAXISTITLE,
in.font.strip = PLOTFONTFACETSTRIP,
in.font.legend = PLOTFONTLEGEND) +
theme(legend.position = input$rBlegendPos)
theme(legend.position = input$rBlegendPos) +
scale_colour_manual(values = loc.col)
return(p.out)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment