Repository navigation
Closed
Description
Description
There're no arrows drew between nodes and the rotation does not work either.
Steps/Code to Reproduce
from sklearn.tree import DecisionTreeClassifier
from sklearn.tree import plot_tree
from sklearn.datasets import load_iris
import matplotlib.pyplot as plt
X, y = load_iris(return_X_y=True)
tree = DecisionTreeClassifier(criterion='gini')
tree.fit(X, y)
fig, ax = plt.subplots(figsize=(10, 10))
plot_tree(tree, rotate=True, ax=ax);Actual Results
Versions
Could not locate executable g77
Could not locate executable f77
Could not locate executable ifort
Could not locate executable ifl
Could not locate executable f90
Could not locate executable DF
Could not locate executable efl
Could not locate executable gfortran
Could not locate executable f95
Could not locate executable g95
Could not locate executable efort
Could not locate executable efc
Could not locate executable flang
don't know how to compile Fortran code on platform 'nt'
System:
python: 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]
executable: C:\Users\liqia\Anaconda3\python.exe
machine: Windows-10-10.0.17763-SP0
BLAS:
macros:
lib_dirs:
cblas_libs: cblas
Python deps:
pip: 19.1
setuptools: 41.0.0
sklearn: 0.21.1
numpy: 1.16.2
scipy: 1.2.1
Cython: 0.29.7
pandas: 0.24.2
C:\Users\liqia\Anaconda3\lib\site-packages\numpy\distutils\system_info.py:638: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
self.calc_info()
C:\Users\liqia\Anaconda3\lib\site-packages\numpy\distutils\system_info.py:638: UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
self.calc_info()
C:\Users\liqia\Anaconda3\lib\site-packages\numpy\distutils\system_info.py:638: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
self.calc_info()
Metadata
Metadata
Assignees
Labels
No labels

Activity
cmarmo commentedon Sep 27, 2019
Hi,
I can't reproduce the arrow problem...
About the rotation: after checking the code, I think that this option is available only for DOT exportation.
See the sklearn.tree.export_graphviz() function.
amueller commentedon Sep 27, 2019
what version of matplotlib are you using?
stevenlis commentedon Sep 28, 2019
@cmarmo @amueller I just tried with Jupyter Lab and it seems like there is something wrong with VS code. If I set

facecolor='k'in Jupyter Lab, it will look like this:Maybe there should be a little boundary around those arrows?
jolespin commentedon Sep 30, 2019
I'm getting the same error with mine. Have you found a fix for this?
astrojuanlu commentedon Nov 21, 2019
Same here, sklearn 0.21.3 and matplotlib 3.1.1 on Jupyter Lab 1.2.3.
cmarmo commentedon Nov 21, 2019
Hi everybody, I've just opened a specific issue about the
rotateproblem (#15694).About the arrows: @jolespin, @StevenLi-DS, could you please let us know which version of matplotlib you are using? Just to understand if scikit-learn can do something here or the problem need to be investigated in the dependencies. Thanks!
stevenlis commentedon Nov 21, 2019
@cmarmo I forgot the comment. I think the issue is not the arrows but the color of the arrows doesn't change dynamically based on the facecolor of the plot.
I can see the arrow now even with a white background, so I think it might be my IDE's issue, i.e. vscode.
However, the arrows are not visible if you change the
facecolor='k'since they don't have a white background below them like the text rectangles.matplotlib: 3.1.1[-]no rotation and no arrows drew betwee nodes in plot_tree[/-][+]add a background color for the arrows in plots by plot_tree[/+]amueller commentedon Jan 6, 2020
Instead of
facecolor='k'you should probably useplt.style.use('dark_background').Though unfortunately we're hard-coding the face color right now, so that doesn't work either. But it seems like we should be able to make that work?
Silly question: what's wrong with just inverting the image?
amueller commentedon Jan 6, 2020
stevenlis commentedon Jan 6, 2020
plt.style.use('dark_background')will affect global settings, so maybe put it in a context manager every time?amueller commentedon Jan 7, 2020
Indeed, that's a better way to do it ;) Same for the rcParams change.
cmarmo commentedon Jan 9, 2020
@amueller, @StevenLi-DS , it seems that everybody is happy now... :)
Closing?
stevenlis commentedon Jan 9, 2020
@cmarmo It would be better if this can be fixed so that the users don't have to set style every time. But if it requires too much time, I think this workaround is ok for me.
cmarmo commentedon Jan 10, 2020
That's why I gave it a try... :)
But @amueller is the one with merging powers... ;)
Maybe he could give me some advice about how to improve my PR (#15940)? Thanks!
NicolasHug commentedon Jan 17, 2020
#13971 (comment) + context manager is a good enough workaround, closing
RushikeshJoshi4 commentedon Nov 18, 2020
I know this is a closed issue, But if anyone is still wondering, using 'jpg' as file extension instead of 'png' in savefig() solved my problem of arrows being invisible. I'm also using VS by the way.