Код ниже использует две опции для изменения размера фигуры ( » означает отступ - пробел )
- fig.set_figheight(4) ; fig.set_figwidth(8)
- fig.set_size_inches(12,6)
(.env) boris@boris-All-Series:~/FIGSIZE$ cat figureSize2.py
import matplotlib.pyplot as plt
import numpy as np
def power(x, y):
» » » » if(y == 0): return 1
» » » » elif (int(y % 2) == 0):
» » » » » » » » return (power(x, int(y / 2)) *
» » » » » » » » » » » » power(x, int(y / 2)))
» » » » else:
» » » » » » » » return (x * power(x, int(y / 2)) *
» » » » » » » » » » » » power(x, int(y / 2)))
x = np.arange(0, 10, 0.1)
y = power(x,4)*np.sin(x)
z = power(x,4)*np.cos(x)
fig = plt.figure()
fig.set_figheight(4)
fig.set_figwidth(8)
# Adds subplot on position 1
ax = fig.add_subplot(121)
# Adds subplot on position 2
ax2 = fig.add_subplot(122)
ax.plot(x, y)
ax2.plot(x, z)
fig = plt.figure()
fig.set_size_inches(12,6)
# Adds subplot on position 1
ax = fig.add_subplot(121)
# Adds subplot on position 2
ax2 = fig.add_subplot(122)
ax.plot(x, y)
ax2.plot(x, z)
plt.show()
