메모
전체 예제 코드를 다운로드 하려면 여기 를 클릭 하십시오.
다중 이미지 #
단일 컬러맵, 노름, 컬러바를 사용하여 이미지 세트를 만듭니다.
from matplotlib import colors
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(19680801)
Nr = 3
Nc = 2
fig, axs = plt.subplots(Nr, Nc)
fig.suptitle('Multiple images')
images = []
for i in range(Nr):
for j in range(Nc):
# Generate data with a range that varies from one plot to the next.
data = ((1 + i + j) / 10) * np.random.rand(10, 20)
images.append(axs[i, j].imshow(data))
axs[i, j].label_outer()
# Find the min and max of all colors for use in setting the color scale.
vmin = min(image.get_array().min() for image in images)
vmax = max(image.get_array().max() for image in images)
norm = colors.Normalize(vmin=vmin, vmax=vmax)
for im in images:
im.set_norm(norm)
fig.colorbar(images[0], ax=axs, orientation='horizontal', fraction=.1)
# Make images respond to changes in the norm of other images (e.g. via the
# "edit axis, curves and images parameters" GUI on Qt), but be careful not to
# recurse infinitely!
def update(changed_image):
for im in images:
if (changed_image.get_cmap() != im.get_cmap()
or changed_image.get_clim() != im.get_clim()):
im.set_cmap(changed_image.get_cmap())
im.set_clim(changed_image.get_clim())
for im in images:
im.callbacks.connect('changed', update)
plt.show()
![여러 이미지](/stable/_images/sphx_glr_multi_image_001.png)
참조
다음 함수, 메서드, 클래스 및 모듈의 사용이 이 예제에 표시됩니다.