Last active
December 9, 2020 12:18
-
-
Save TooTouch/b2bdb9fd205ea5a411ede796b12ebf91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from matplotlib.pyplot import imread | |
def cat_plot(cluster: list, save=False): | |
# 이미지 불러오기 | |
cat_images = [imread(f'../images/category icon/mcorp_sample/cat{i+1}.png') for i in range(15)] | |
legend_image = imread('../images/category icon/mcorp_sample/legend.png') | |
# 이미지 삽입 | |
plt.figure(figsize=(11,6)) | |
# 레벨 | |
plt.imshow(legend_image, extent=[-10, 115, 0, 13]) | |
for i, image in enumerate(cat_images): | |
# 군집 이외의 ID는 불투명 상태로 변환 | |
alpha = 1 if i in cluster else 0.1 | |
height, width, space, bottom = 13, 20, 1, 3 | |
height += 10*(4-(i%3+1)) | |
bottom += 10*(4-(i%3+1)) | |
if i % 3 == 0: | |
left = width*(i/3) + space*(i/3) | |
right = left + width | |
plt.imshow(image, extent=[left, right, bottom, height], alpha=alpha) | |
plt.xlim(-10,115) | |
plt.ylim(0,46) | |
plt.axis('off') | |
plt.tight_layout() | |
if save: | |
plt.savefig('../images/sample/cat_example.jpg',dpi=300) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment