You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tree.plot_tree() does not visualize properly if also using seaborn.set_style() #16943
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
In a sense it's the opposite problem. In #13971 the user tried to change the color, which you can do via the RC. Here, @jlewis-ds changed the rc colors but didn't want it to affect the output.
We can either hard-code the colors and people can't change the colors, or we can use the colors that user specified.
Here, it's axes.edgecolor I think that is set by nearly all styles in seaborn. So it looks like the seaborn styles intentionally hide all arrows or borders or really anything that's not given explicit color.
We could use a different color, say the text color, to draw the arrows. But that's basically hacking around the opinion of seaborn. Seaborn asked for all borders to be white, and all borders turn white.
#17187 looks like a good work around. I was hesitant to report this as a bug since technically everything is doing what it's supposed to, but it seemed like an unintentional result which could easily be overlooked.
Activity
cmarmo commentedon Apr 20, 2020
Hi @jlewis-ds this is probably related to #13971 because of the
whitegridseaborn definition.@amueller is the most suitable to give you an answer.
amueller commentedon May 11, 2020
In a sense it's the opposite problem. In #13971 the user tried to change the color, which you can do via the RC. Here, @jlewis-ds changed the rc colors but didn't want it to affect the output.
We can either hard-code the colors and people can't change the colors, or we can use the colors that user specified.
Here, it's
axes.edgecolorI think that is set by nearly all styles in seaborn. So it looks like the seaborn styles intentionally hide all arrows or borders or really anything that's not given explicit color.We could use a different color, say the text color, to draw the arrows. But that's basically hacking around the opinion of seaborn. Seaborn asked for all borders to be white, and all borders turn white.
amueller commentedon May 11, 2020
I would say this is the pragmatic solution: #17187
it keeps some of the styling while also making sure the arrows are drawn.
jlewis-ds commentedon May 11, 2020
#17187 looks like a good work around. I was hesitant to report this as a bug since technically everything is doing what it's supposed to, but it seemed like an unintentional result which could easily be overlooked.
Thanks, I'm happy to call this closed.