-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
plot_tree squished to bottom left in saved fig if DPI is increased #19866
Copy link
Copy link
Closed
Description
Describe the bug
I didn't see this in other issues but maybe it's there. When saving a figure, if you change the DPI from the default to increase the resolution, the saved figure is squished to the bottom left of the image.
Steps/Code to Reproduce
See this github repo for examples:
https://github.com/nateGeorge/sklearn_plot_tree_bug
Increasing DPI causes the figure to be squished to the bottom left:
f = plt.figure(figsize=(10, 10))
plot_tree(dt, fontsize=8, feature_names=features.columns, filled=True)
plt.savefig('decision_tree.jpg', dpi=300)
plt.show()Expected Results
I would expect the DPI argument in plt.savefig() to increase the resolution, but the original layout of the figure would be the same.
Actual Results
When saving the figure with higher DPI (the image is mostly white space):

Versions
System:
python: 3.8.8 (default, Feb 24 2021, 15:54:32) [MSC v.1928 64 bit (AMD64)]
executable: C:\Users\words\Anaconda3\envs\msds\python.exe
machine: Windows-10-10.0.19041-SP0
Python dependencies:
pip: 21.0.1
setuptools: 49.6.0.post20210108
sklearn: 0.24.1
numpy: 1.20.2
scipy: 1.6.2
Cython: None
pandas: 1.2.3
matplotlib: 3.4.1
joblib: 1.0.1
threadpoolctl: 2.1.0
Built with OpenMP: TrueReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels