Skip to Content
Numerical Computing with Python
book

Numerical Computing with Python

by Pratap Dangeti, Allen Yu, Claire Chung, Aldrin Yim
December 2018
Beginner to intermediate
682 pages
18h 1m
English
Packt Publishing
Content preview from Numerical Computing with Python

Changing the size of the figure

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:

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Numerical Computing with NumPy

Mastering Numerical Computing with NumPy

Umit Mert Cakmak, Tiago Antao, Mert Cuhadaroglu

Publisher Resources

ISBN: 9781789953633OtherOtherErrata Page