728x90

ref : https://matplotlib.org/api/_as_gen/matplotlib.pyplot.subplots.html

 

 

 

1. 1 x 2 열 subplot

 

 

import numpy as np
import matplotlib.pyplot as plt

# First create some toy data:
x = np.linspace(0, 2*np.pi, 400)
y = np.sin(x**2)

# Create two subplots and unpack the output array immediately
f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
ax1.plot(x, y)
ax1.set_title('Sharing Y axis')
ax2.scatter(x, y)

plt.show()

 

 

2. 2x2 서브플롯 생성

 

 

import numpy as np
import matplotlib.pyplot as plt

# First create some toy data:
x = np.linspace(0, 2*np.pi, 400)
y = np.sin(x**2)

# Create four4 axes and access them through the returned array
fig, axs = plt.subplots(2, 2)
axs[0, 0].plot(x, y)
axs[1, 1].scatter(x, y)

plt.show()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

300x250

+ Recent posts