December 2018
Beginner to intermediate
682 pages
18h 1m
English
To control the height and width of the figure, we can rely on matplotlib.pyplot.figure(figsize=(WIDTH,HEIGHT)) as well.
In this example, we are going to change the size of the previous histogram example to 8 inches wide and 4 inches tall:
import seaborn as snsimport matplotlib.pyplot as pltfrom scipy import stats# Note: Codes related to data preparation are skipped for brevity# Reset all previous theme settings to defaultssns.set()# Change the size to 8 inches wide and 4 inches tallfig = plt.figure(figsize=(8,4))# We are going to reuse current_bigmac that was generated earlier# Plot the histogramax = sns.distplot(current_bigmac.dollar_price)plt.show()
Here is the expected output from the preceding code: