[PYTHON] How to avoid the cut-off label of the graph created by the plot module using matplotlib

Introduction

When saving the graph output by the graph plot method that uses matplotlib internally, the axis label may be cut off. Since the layout is set in the method, it is difficult to adjust it, but I will write down how to adjust it well.

manner

You can call the tight_layout method of pylab (or matplotlib.pylab).

The graph layout is changed so that the axis labels and memory labels in the graph can be output well.

The following is an example of the shap module with summary_plot.

shap summary_Example in plot


shap.summary_plot(shap_values, X, show=False)
pylab.tight_layout()
plt.savefig('./shap.png')

reference

-bbox_inches = "tight" or something like that --virsalus diary

Recommended Posts

How to avoid the cut-off label of the graph created by the plot module using matplotlib
How to plot a lot of legends by changing the color of the graph continuously with matplotlib
Paste a link to the data point of the graph created by jupyterlab & matplotlib
How to draw a graph using Matplotlib
How to access the global variable of the imported module
How to confirm the Persival theorem using the Fourier transform (FFT) of matplotlib and scipy
How to test the attributes added by add_request_method of pyramid
(Note) How to pass the path of your own module
How to use the optparse module
[TensorFlow 2] How to check the contents of Tensor in graph mode
How to use the ConfigParser module
[Python] How to specify the window display position and size of matplotlib
How to easily switch the virtual environment created by Conda on Jupyter
How to find out the number of CPUs without using the sar command
How to check the version of Django
Create a graph using the Sympy module
[Circuit x Python] How to find the transfer function of a circuit using Lcapy
How to plot multiple fits images side by side in galactic coordinates using python
[python] How to sort by the Nth Mth element of a multidimensional array
Save an array of numpy to a wav file using the wave module
Checklist on how to avoid turning the elements of numpy's array with for
How to calculate the volatility of a brand
How to find the area of the Voronoi diagram
How to avoid writing% matplotlib inline every time
How to use the graph drawing library Bokeh
How to erase the characters output by Python
I tried using the Datetime module by Python
Try using the collections module (ChainMap) of python3
The basis of graph theory with matplotlib animation
How to uninstall a module installed using setup.py
[Python] You can save an object to a file by using the pickle module.
[Ruby] How to replace only a part of the string matched by the regular expression?
I want to add my own structure to the structure created by Python's C extension module!
How to extract conditions (acquire all elements of Group that satisfy the conditions) for Group by Group
How to know the port number of the xinetd service
How to run the Ansible module added in Ansible Tower
I tried to summarize how to use matplotlib of python
[Python] How to draw a line graph with Matplotlib
Add information to the bottom of the figure with Matplotlib
Omit the decimal point of the graph scale in matplotlib
How to visualize the decision tree model of scikit-learn
[Statistics] Understand the mechanism of Q-Q plot by animation.
Save the graph drawn by pyqtgraph to an image
Drawing on Jupyter using the plot function of pandas
[Python] How to use the graph creation library Altair
Write data to KINTONE using the Python requests module
How to check the Java version used by Maven
[Blender] How to dynamically set the selection of EnumProperty
[Python] Summary of how to specify the color of the figure
How to hit the document of Magic Function (Line Magic)
[Introduction to Python] How to stop the loop using break?
How to add color bars in matplotlib bar plot
[Introduction to Python] Basic usage of the library matplotlib
The story of using circleci to build manylinux wheels
[Python] How to draw a scatter plot with Matplotlib
[Selenium] How to specify the relative path of chromedriver?
I tried to complement the knowledge graph using OpenKE
How to unprefix the DB name used by pytest-django
[Python] I want to make a 3D scatter plot of the epicenter with Cartopy + Matplotlib!
How to check if the contents of the dictionary are the same in Python by hash value
How to change the MAC address of an automatically created virtual NIC to be event driven