Change color and legend of plotLearnerPrediction ggplot2 object -
i've been producing number of nice plots plotlearnerprediction function in mlr package r. this. looking source code of plotlearnerprediction function looks color surfaces made geom_tile. plot can example made by:
library(mlr) data(iris) #make learner lrn <- "classif.qda" #make task my.task <- makeclassiftask(data = iris, target = "species") #make plot plotlearnerprediction(learner = lrn, task = my.task)
now wish change colors, using red, blue , green tone match of other plots i've made project. tried scale_fill_continuous
, scale_fill_manual
without luck (error: discrete value supplied continuous scale) wish change legend title , labels each legend entry (which tried giving appropriate parameters above scale_fill
's). there's lot of info out there on how set geom_tile colours when producing plot, haven't found info on how post-production (i.e. in else's plot object). appreciated.
when source code see how plot generated , can see scale has overwritten or set.
in example it's easy:
g = plotlearnerprediction(learner = lrn, task = my.task) library(ggplot2) g + scale_fill_manual(values = c(setosa = "yellow", versicolor = "blue", virginica = "red"))
Comments
Post a Comment