I have plotted the importance matrix in xgboosot and I want to make the text bigger, how do I do that?
gg <- xgb.ggplot.importance(importance_matrix = a,top_n = 15)
I have plotted the importance matrix in xgboosot and I want to make the text bigger, how do I do that?
gg <- xgb.ggplot.importance(importance_matrix = a,top_n = 15)
Use theme()
to increased the font size.
Below, I have given a minimum reproducible example;
# Load library
library(ggplot2)
require(xgboost)
# load data
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
train <- agaricus.train
test <- agaricus.test
# create model
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
eta = 1, nthread = 2, nround = 2, objective = "binary:logistic")
# importance matrix
imp_matrix <- xgb.importance(colnames(agaricus.train$data), model = bst)
# plot
xgb.ggplt<-xgb.ggplot.importance(importance_matrix = imp_matrix, top_n = 4)
# increase the font size for x and y axis
xgb.ggplt+theme( text = element_text(size = 20),
axis.text.x = element_text(size = 15, angle = 45, hjust = 1))
Use ?theme to see the list of parameters you can modify.