figsize matlob adjust in python

To adjust figure size in matplotlib, we can use figure() method from matplotlib. We can pass figsize parameter to it to set the size of the figure. Here's an example:

main.py
import matplotlib.pyplot as plt

# create a figure with figsize parameter
fig = plt.figure(figsize=(8, 6))

# plot a chart using the figure
plt.plot([1, 2, 3, 4], [1, 2, 3, 4])

# show the chart
plt.show()
206 chars
11 lines

In the above code, we created a figure with a size of 8 inches in width and 6 inches in height using figsize=(8, 6) parameter. Then we plotted a chart using the same figure and displayed it using plt.show() method. By default, the figure size is set to (6.4, 4.8) so we can use bigger size if we want to display bigger chart.

related categories

gistlibby LogSnag