When you save the figure with all the default options, sometimes it may get truncated. In this recipe, we will learn how to avoid such issues.
Avoiding truncation while saving the figure
Getting ready
Import the required libraries:
import matplotlib.pyplot as plt
import numpy as np
How to do it...
The following code block plots a histogram and saves it with the default parameters, using the bbox_inches='tight' parameter, followed by the addition of pad_inches=1:
- Set the seed for repeatability and define the figure with figsize:
np.random.seed(19681211)
plt.figure...