首页 > 解决方案 > XGBOOST:不能翻转轴的重要性 - 特征图

问题描述

我正在尝试翻转轴,以便Features在 X 轴上。以下代码给了我一个系统覆盖轴的错误。

    >gplt = xgb.ggplot.importance (importance_matrix = xgb.importance(model =model_xgb) , top_n = 10 , n_clusters = 1 ) 
                                                   +theme(legend.position = "none" , text = element_text(size = 20))

    >gplt +coord_flip()


    #[OUTPUT]:

    Coordinate system already present. Adding new coordinate system, which will replace the existing one.

标签: rggplot2xgboost

解决方案


如果您查看 的代码xgb.ggplot.importance,您会看到它包含对 的调用coord_flip,并且调用它两次不会改变任何内容。为了得到你想要的,你可以做

gplt + coord_cartesian()

您仍然会看到该消息,但您的轴应该翻转。


推荐阅读