Python 如何调整sklearn中plot_树图形的大小以使其可读?

Python 如何调整sklearn中plot_树图形的大小以使其可读?,python,matplotlib,scikit-learn,tree,Python,Matplotlib,Scikit Learn,Tree,我正试图用matplotlib从sklearn绘制plot\u tree对象,但我的树形图看起来不太好。我的树林看起来被压扁了: 以下是我的代码: from sklearn import tree from sklearn.model_selection import cross_val_score from sklearn.metrics import accuracy_score import matplotlib.pyplot as plt # create tree object

我正试图用
matplotlib
sklearn
绘制
plot\u tree
对象,但我的树形图看起来不太好。我的树林看起来被压扁了:

以下是我的代码:

from sklearn import tree
from sklearn.model_selection import cross_val_score
from sklearn.metrics import accuracy_score
import matplotlib.pyplot as plt

# create tree object 
model_gini_class = tree.DecisionTreeClassifier(criterion='gini')

# train the model using the training sets and check score
model_gini_class.fit(X_train, y_train)
model_gini_class.score(X_train, y_train)

# predict output
predicted_gini_class = model_gini_class.predict(X_test)

plt.figure()
tree.plot_tree(model_gini_class, filled=True)
plt.title("Decision trees on the Shakespear dataset (Gini)")
plt.show() # the tree looks squished?
所以我的问题是:

  • 有人能告诉我如何调整
    sklearn
    plot\u树对象的大小,使其看起来不会被压扁吗
谢谢,

这可能会有帮助

plt.figure(figsize=(10,10))
from matplotlib import pyplot as plt
fig, axes = plt.subplots(nrows = 1,ncols = 1,figsize = (5,5), dpi=300)
tree.plot_tree(model_gini_class, filled=True)
这可能会有帮助

plt.figure(figsize=(10,10))
from matplotlib import pyplot as plt
fig, axes = plt.subplots(nrows = 1,ncols = 1,figsize = (5,5), dpi=300)
tree.plot_tree(model_gini_class, filled=True)