Skip to content

tree.plot_tree() does not visualize properly if also using seaborn.set_style()  #16943

@jlewis-ds

Description

@jlewis-ds

Describe the bug

If using scikit-learn and seaborn together, when using sns.set_style() the plot output from tree.plot_tree() only produces the labels of each split. It does not produce the nodes or arrows to actually visualize the tree.

Steps/Code to Reproduce

import seaborn as sns
sns.set_style('whitegrid') #Note: this can be any option for set_style
from sklearn.datasets import load_iris
from sklearn import tree

clf = tree.DecisionTreeClassifier(random_state=0)
iris = load_iris()
clf = clf.fit(iris.data, iris.target)
plt.show(tree.plot_tree(clf))

Expected Results

Tree is properly visualized.

Actual Results

Only labels are produced, not the tree itself.

Versions

System:
python: 3.7.7 (default, Mar 23 2020, 23:19:08) [MSC v.1916 64 bit (AMD64)]
executable: C:\Users\jlewis\AppData\Local\Continuum\anaconda3\python.exe
machine: Windows-10-10.0.17763-SP0

Python dependencies:
pip: 20.0.2
setuptools: 46.1.3.post20200330
sklearn: 0.22.1
numpy: 1.18.1
scipy: 1.4.1
Cython: None
pandas: 1.0.3
matplotlib: 3.1.3
joblib: 0.14.1

Built with OpenMP: True
tree_plot

tree_plot_with_setstyle

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions