import matplotlib.pyplot as plt fig = plt.figure(figsize=(6, 4)) h = fig.get_figheight() print(f"The figure height is {h} inches.")
The figure height is 4.0 inches.
import matplotlib.pyplot as plt fig1 = plt.figure(figsize=(8, 6)) fig2 = plt.figure(figsize=(4, 2)) h1 = fig1.get_figheight() h2 = fig2.get_figheight() print(f"fig1 height: {h1} inches") print(f"fig2 height: {h2} inches")
fig1 height: 6.0 inches fig2 height: 2.0 inchesIn this example, we create two Figure objects with different sizes. We then call the get_figheight method on each of the figures to retrieve their heights in inches and print them to the console. Package/library: Matplotlib.