我在xgboosot中绘制了重要性矩阵,我想让文字更大,我该怎么做?
gg <- xgb.ggplot.importance(importance_matrix = a,top_n = 15)
答案 0 :(得分:1)
使用theme()
增加字体大小。
下面,我给出了一个可重复性最小的例子;
# 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))
使用?theme查看您可以修改的参数列表。