반응형
matplotlib 그래프¶
In [1]:
!pip install --upgrade --force-reinstall seaborn
Defaulting to user installation because normal site-packages is not writeable Collecting seaborn Downloading seaborn-0.13.2-py3-none-any.whl (294 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 294.9/294.9 kB 6.4 MB/s eta 0:00:00a 0:00:01 Collecting numpy!=1.24.0,>=1.20 Downloading numpy-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.3/19.3 MB 56.4 MB/s eta 0:00:0000:0100:01 Collecting matplotlib!=3.6.1,>=3.4 Downloading matplotlib-3.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.3/8.3 MB 56.5 MB/s eta 0:00:0000:0100:01 Collecting pandas>=1.2 Downloading pandas-2.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.1/13.1 MB 82.4 MB/s eta 0:00:0000:0100:01 Collecting contourpy>=1.0.1 Downloading contourpy-1.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (304 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 305.0/305.0 kB 40.2 MB/s eta 0:00:00 Collecting python-dateutil>=2.7 Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 229.9/229.9 kB 32.2 MB/s eta 0:00:00 Collecting pillow>=8 Downloading pillow-10.3.0-cp39-cp39-manylinux_2_28_x86_64.whl (4.5 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.5/4.5 MB 47.4 MB/s eta 0:00:0000:0100:01 Collecting importlib-resources>=3.2.0 Downloading importlib_resources-6.4.0-py3-none-any.whl (38 kB) Collecting kiwisolver>=1.3.1 Downloading kiwisolver-1.4.5-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.6 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.6/1.6 MB 63.8 MB/s eta 0:00:00 Collecting packaging>=20.0 Downloading packaging-24.1-py3-none-any.whl (53 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 54.0/54.0 kB 5.4 MB/s eta 0:00:00 Collecting cycler>=0.10 Downloading cycler-0.12.1-py3-none-any.whl (8.3 kB) Collecting fonttools>=4.22.0 Downloading fonttools-4.53.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.6 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.6/4.6 MB 90.9 MB/s eta 0:00:00:00:01 Collecting pyparsing>=2.3.1 Downloading pyparsing-3.1.2-py3-none-any.whl (103 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 103.2/103.2 kB 11.6 MB/s eta 0:00:00 Collecting pytz>=2020.1 Downloading pytz-2024.1-py2.py3-none-any.whl (505 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 505.5/505.5 kB 34.0 MB/s eta 0:00:00 Collecting tzdata>=2022.7 Downloading tzdata-2024.1-py2.py3-none-any.whl (345 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 345.4/345.4 kB 31.2 MB/s eta 0:00:00 Collecting zipp>=3.1.0 Downloading zipp-3.19.2-py3-none-any.whl (9.0 kB) Collecting six>=1.5 Downloading six-1.16.0-py2.py3-none-any.whl (11 kB) Installing collected packages: pytz, zipp, tzdata, six, pyparsing, pillow, packaging, numpy, kiwisolver, fonttools, cycler, python-dateutil, importlib-resources, contourpy, pandas, matplotlib, seaborn Attempting uninstall: pytz Found existing installation: pytz 2022.5 Uninstalling pytz-2022.5: Successfully uninstalled pytz-2022.5 Attempting uninstall: zipp Found existing installation: zipp 3.10.0 Uninstalling zipp-3.10.0: Successfully uninstalled zipp-3.10.0 Attempting uninstall: six Found existing installation: six 1.16.0 Uninstalling six-1.16.0: Successfully uninstalled six-1.16.0 Attempting uninstall: pyparsing Found existing installation: pyparsing 3.0.9 Uninstalling pyparsing-3.0.9: Successfully uninstalled pyparsing-3.0.9 Attempting uninstall: pillow Found existing installation: Pillow 9.3.0 Uninstalling Pillow-9.3.0: Successfully uninstalled Pillow-9.3.0 Attempting uninstall: packaging Found existing installation: packaging 21.3 Uninstalling packaging-21.3: Successfully uninstalled packaging-21.3 Attempting uninstall: numpy Found existing installation: numpy 1.23.3 Uninstalling numpy-1.23.3: Successfully uninstalled numpy-1.23.3 Attempting uninstall: kiwisolver Found existing installation: kiwisolver 1.4.4 Uninstalling kiwisolver-1.4.4: Successfully uninstalled kiwisolver-1.4.4 Attempting uninstall: fonttools Found existing installation: fonttools 4.38.0 Uninstalling fonttools-4.38.0: Successfully uninstalled fonttools-4.38.0 Attempting uninstall: cycler Found existing installation: cycler 0.11.0 Uninstalling cycler-0.11.0: Successfully uninstalled cycler-0.11.0 Attempting uninstall: python-dateutil Found existing installation: python-dateutil 2.8.2 Uninstalling python-dateutil-2.8.2: Successfully uninstalled python-dateutil-2.8.2 Attempting uninstall: contourpy Found existing installation: contourpy 1.0.6 Uninstalling contourpy-1.0.6: Successfully uninstalled contourpy-1.0.6 Attempting uninstall: pandas Found existing installation: pandas 1.4.2 Uninstalling pandas-1.4.2: Successfully uninstalled pandas-1.4.2 Attempting uninstall: matplotlib Found existing installation: matplotlib 3.6.0 Uninstalling matplotlib-3.6.0: Successfully uninstalled matplotlib-3.6.0 Attempting uninstall: seaborn Found existing installation: seaborn 0.12.0 Uninstalling seaborn-0.12.0: Successfully uninstalled seaborn-0.12.0 ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. scipy 1.8.1 requires numpy<1.25.0,>=1.17.3, but you have numpy 2.0.0 which is incompatible. Successfully installed contourpy-1.2.1 cycler-0.12.1 fonttools-4.53.0 importlib-resources-6.4.0 kiwisolver-1.4.5 matplotlib-3.9.0 numpy-2.0.0 packaging-24.1 pandas-2.2.2 pillow-10.3.0 pyparsing-3.1.2 python-dateutil-2.9.0.post0 pytz-2024.1 seaborn-0.13.2 six-1.16.0 tzdata-2024.1 zipp-3.19.2 [notice] A new release of pip available: 22.2.2 -> 24.1.1 [notice] To update, run: pip install --upgrade pip
모듈 Import¶
In [2]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
# Unicode warning 제거 (폰트 관련 경고메시지)
plt.rcParams['axes.unicode_minus']=False
# 한글 폰트 설정
plt.rcParams['font.family'] = "NanumGothic"
# 그래프 출력 사이즈 설정
plt.rcParams["figure.figsize"] = (12, 10)
Scatterplot¶
0 ~ 1 사이의 임의의 랜덤한 값을 생성합니다.
In [3]:
np.random.rand(50)
Out[3]:
array([0.62881031, 0.42937313, 0.78624726, 0.58871169, 0.24828663, 0.03681471, 0.85600288, 0.50050205, 0.260603 , 0.69850733, 0.56113708, 0.860106 , 0.79483302, 0.45692983, 0.54384138, 0.47542397, 0.09426981, 0.3702961 , 0.21580396, 0.51580194, 0.45960071, 0.91801268, 0.91253519, 0.75383199, 0.89420131, 0.0890961 , 0.64751513, 0.09491463, 0.97345499, 0.18921112, 0.55480593, 0.68921671, 0.9243705 , 0.5243626 , 0.781508 , 0.70847555, 0.99692983, 0.50728519, 0.00788625, 0.25956128, 0.50683897, 0.92157855, 0.00652356, 0.65054316, 0.76185927, 0.70391341, 0.31149907, 0.02614032, 0.27916092, 0.9953763 ])
x, y, colors, area 설정하기¶
- colors 는 임의 값을 color 값으로 변환합니다.
- area는 점의 넓이를 나타냅니다. 값이 커지면 당연히 넓이도 커집니다.
In [4]:
x = np.random.rand(50)
y = np.random.rand(50)
colors = np.arange(50)
area = x * y * 250
In [5]:
plt.scatter(x, y, s=area, c=colors)
plt.show()
color, alpha¶
- color에 컬러를 지정하면, 컬러 값을 모두 같게 가져갈 수도 있습니다.
- alpha값은 투명도를 나타내며 0 ~ 1 사이의 값을 지정해 줄 수 있으며, 0에 가까울 수록 투명한 값을 가집니다.
In [6]:
np.random.rand(50)
Out[6]:
array([0.24557946, 0.44399065, 0.31220244, 0.93847529, 0.04239565, 0.37289896, 0.40686842, 0.94386493, 0.94232699, 0.93225503, 0.25688768, 0.91783008, 0.57507472, 0.13402612, 0.7316266 , 0.50171634, 0.70980674, 0.22579066, 0.73296916, 0.87460534, 0.61589997, 0.91675269, 0.14489578, 0.54333542, 0.64616292, 0.37452708, 0.85776254, 0.15532672, 0.2286975 , 0.58649138, 0.31110777, 0.9368848 , 0.76920667, 0.57317576, 0.71403262, 0.20433079, 0.25853246, 0.53995399, 0.14023826, 0.07321291, 0.56570372, 0.28921533, 0.79367733, 0.10096392, 0.31030015, 0.17688359, 0.16222511, 0.6619724 , 0.54803703, 0.73946328])
In [7]:
plt.figure(figsize=(12, 6))
plt.subplot(131)
plt.scatter(x, y, s=area, color='purple', alpha=0.1)
plt.title('alpha=0.1')
plt.subplot(132)
plt.title('alpha=0.5')
plt.scatter(x, y, s=area, color='purple', alpha=0.5)
plt.subplot(133)
plt.title('alpha=1.0')
plt.scatter(x, y, s=area, color='purple', alpha=1.0)
plt.show()
Barplot, Barhplot¶
1개의 canvas 안에 다중 그래프 그리기
Barplot 생성¶
In [8]:
x = ['Math', 'Programming', 'Data Science', 'Art', 'English', 'Physics']
y = [66, 80, 60, 50, 80, 10]
plt.figure(figsize=(6, 3))
# plt.bar(x, y)
plt.bar(x, y, align='center', alpha=0.7, color='red')
plt.xticks(x)
plt.ylabel('Number of Students')
plt.title('Subjects')
plt.show()
Barhplot (축 변환)¶
barh 함수에서는 xticks로 설정했던 부분을 yticks로 변경합니다.
In [9]:
x = ['Math', 'Programming', 'Data Science', 'Art', 'English', 'Physics']
y = [66, 80, 60, 50, 80, 10]
plt.barh(x, y, align='center', alpha=0.7, color='green')
plt.yticks(x)
plt.xlabel('Number of Students')
plt.title('Subjects')
plt.show()
Barplot에서 비교 그래프 그리기¶
In [10]:
x_label = ['Math', 'Programming', 'Data Science', 'Art', 'English', 'Physics']
x = np.arange(len(x_label))
y_1 = [66, 80, 60, 50, 80, 10]
y_2 = [55, 90, 40, 60, 70, 20]
# 넓이 지정
width = 0.35
# subplots 생성
fig, axes = plt.subplots()
# 넓이 설정
axes.bar(x - width/2, y_1, width, align='center', alpha=0.5)
axes.bar(x + width/2, y_2, width, align='center', alpha=0.8)
# xtick 설정
plt.xticks(x)
axes.set_xticklabels(x_label)
plt.ylabel('Number of Students')
plt.title('Subjects')
plt.legend(['john', 'peter'])
plt.show()
In [11]:
x_label = ['Math', 'Programming', 'Data Science', 'Art', 'English', 'Physics']
x = np.arange(len(x_label))
y_1 = [66, 80, 60, 50, 80, 10]
y_2 = [55, 90, 40, 60, 70, 20]
# 넓이 지정
width = 0.35
# subplots 생성
fig, axes = plt.subplots()
# 넓이 설정
axes.barh(x - width/2, y_1, width, align='center', alpha=0.5, color='green')
axes.barh(x + width/2, y_2, width, align='center', alpha=0.8, color='red')
# xtick 설정
plt.yticks(x)
axes.set_yticklabels(x_label)
plt.xlabel('Number of Students')
plt.title('Subjects')
plt.legend(['john', 'peter'])
plt.show()
Line Plot¶
기본 lineplot 그리기¶
In [12]:
x = np.arange(0, 10, 0.1)
y = 1 + np.sin(x)
plt.plot(x, y)
plt.xlabel('x value', fontsize=15)
plt.ylabel('y value', fontsize=15)
plt.title('sin graph', fontsize=18)
plt.grid()
plt.show()
2개 이상의 그래프 그리기¶
- color: 컬러 옵션
- alpha: 투명도 옵션
In [13]:
x = np.arange(0, 10, 0.1)
y_1 = 1 + np.sin(x)
y_2 = 1 + np.cos(x)
plt.plot(x, y_1, label='1+sin', color='blue', alpha=0.3)
plt.plot(x, y_2, label='1+cos', color='red', alpha=0.7)
plt.xlabel('x value', fontsize=15)
plt.ylabel('y value', fontsize=15)
plt.title('sin and cos graph', fontsize=18)
plt.grid()
plt.legend()
plt.show()
마커 스타일링¶
- marker: 마커 옵션
In [14]:
x = np.arange(0, 10, 0.1)
y_1 = 1 + np.sin(x)
y_2 = 1 + np.cos(x)
plt.plot(x, y_1, label='1+sin', color='blue', alpha=0.3, marker='o')
plt.plot(x, y_2, label='1+cos', color='red', alpha=0.7, marker='+')
plt.xlabel('x value', fontsize=15)
plt.ylabel('y value', fontsize=15)
plt.title('sin and cos graph', fontsize=18)
plt.grid()
plt.legend()
plt.show()
라인 스타일 변경¶
- linestyle: 라인 스타일 변경 옵션
In [15]:
x = np.arange(0, 10, 0.1)
y_1 = 1 + np.sin(x)
y_2 = 1 + np.cos(x)
plt.plot(x, y_1, label='1+sin', color='blue', linestyle=':')
plt.plot(x, y_2, label='1+cos', color='red', linestyle='-.')
plt.xlabel('x value', fontsize=15)
plt.ylabel('y value', fontsize=15)
plt.title('sin and cos graph', fontsize=18)
plt.grid()
plt.legend()
plt.show()
Areaplot (Filled Area)¶
matplotlib에서 area plot을 그리고자 할 때는 fill_between 함수를 사용합니다.
In [16]:
y = np.random.randint(low=5, high=10, size=20)
y
Out[16]:
array([8, 8, 7, 7, 9, 6, 8, 7, 6, 5, 6, 5, 9, 6, 8, 6, 6, 7, 5, 5])
기본 areaplot 그리기¶
In [17]:
x = np.arange(1,21)
y = np.random.randint(low=5, high=10, size=20)
# fill_between으로 색칠하기
plt.fill_between(x, y, color="green", alpha=0.6)
plt.show()
경계선을 굵게 그리고 area는 옅게 그리는 효과 적용¶
In [18]:
plt.fill_between(x, y, color="green", alpha=0.3)
plt.plot(x, y, color="green", alpha=0.8)
Out[18]:
[<matplotlib.lines.Line2D at 0x7efe8ff1de50>]
여러 그래프를 겹쳐서 표현¶
In [19]:
x = np.arange(1, 10, 0.05)
y_1 = np.cos(x)+1
y_2 = np.sin(x)+1
y_3 = y_1 * y_2 / np.pi
plt.fill_between(x, y_1, color="green", alpha=0.1)
plt.fill_between(x, y_2, color="blue", alpha=0.2)
plt.fill_between(x, y_3, color="red", alpha=0.3)
Out[19]:
<matplotlib.collections.PolyCollection at 0x7efe8ffcb610>
Histogram¶
기본 Histogram 생성¶
In [20]:
N = 100000
bins = 30
x = np.random.randn(N)
plt.hist(x, bins=bins)
plt.show()
- sharey: y축을 다중 그래프가 share
- tight_layout: graph의 패딩을 자동으로 조절해주어 fit한 graph를 생성
다중 Histogram, bin의 크기변화¶
In [21]:
N = 100000
bins = 30
x = np.random.randn(N)
fig, axs = plt.subplots(1, 3,
sharey=True,
tight_layout=True
)
fig.set_size_inches(12, 5)
axs[0].hist(x, bins=bins)
axs[1].hist(x, bins=bins*2)
axs[2].hist(x, bins=bins*4)
plt.show()
Y축에 Density 표기¶
In [22]:
N = 100000
bins = 30
x = np.random.randn(N)
fig, axs = plt.subplots(1, 2,
tight_layout=True
)
fig.set_size_inches(9, 3)
# density=True 값을 통하여 Y축에 density를 표기할 수 있습니다.
axs[0].hist(x, bins=bins, density=True, cumulative=True)
axs[1].hist(x, bins=bins, density=True)
plt.show()
Pie Chart¶
pie chart 옵션
- explode: 파이에서 툭 튀어져 나온 비율
- autopct: 퍼센트 자동으로 표기
- shadow: 그림자 표시
- startangle: 파이를 그리기 시작할 각도
texts, autotexts 인자를 리턴 받습니다.
texts는 label에 대한 텍스트 효과를
autotexts는 파이 위에 그려지는 텍스트 효과를 다룰 때 활용합니다.
In [23]:
labels = ['Samsung', 'Huawei', 'Apple', 'Xiaomi', 'Oppo', 'Etc']
sizes = [20.4, 15.8, 10.5, 9, 7.6, 36.7]
explode = (0.3, 0, 0, 0, 0, 0)
# texts, autotexts 인자를 활용하여 텍스트 스타일링을 적용합니다
patches, texts, autotexts = plt.pie(sizes,
explode=explode,
labels=labels,
autopct='%1.1f%%',
shadow=True,
startangle=90)
plt.title('Smartphone pie', fontsize=15)
# label 텍스트에 대한 스타일 적용
for t in texts:
t.set_fontsize(12)
t.set_color('gray')
# pie 위의 텍스트에 대한 스타일 적용
for t in autotexts:
t.set_color("white")
t.set_fontsize(10)
plt.show()
Box Plot¶
샘플 데이터를 생성합니다.
In [24]:
# 샘플 데이터 생성
spread = np.random.rand(50) * 100
center = np.ones(25) * 50
flier_high = np.random.rand(10) * 100 + 100
flier_low = np.random.rand(10) * -100
data = np.concatenate((spread, center, flier_high, flier_low))
기본 박스플롯 생성¶
In [25]:
plt.boxplot(data)
plt.tight_layout()
plt.show()
Box Plot 축 바꾸기¶
vert=False 옵션을 통해 표시하고자 하는 축을 바꿀 수 있습니다.
In [26]:
plt.title('Horizontal Box Plot', fontsize=15)
plt.boxplot(data, vert=False)
plt.show()
Outlier 마커 심볼과 컬러 변경¶
In [27]:
outlier_marker = dict(markerfacecolor='r', marker='D')
In [28]:
plt.title('Changed Outlier Symbols', fontsize=15)
plt.boxplot(data, flierprops=outlier_marker)
plt.show()
3D 그래프¶
3d 로 그래프를 그리기 위해서는 mplot3d
를 추가로 import 합니다
In [29]:
from mpl_toolkits import mplot3d
밑그림 그리기 (캔버스)¶
In [30]:
fig = plt.figure()
ax = plt.axes(projection='3d')
3d plot 그리기¶
In [31]:
# project=3d로 설정합니다
ax = plt.axes(projection='3d')
# x, y, z 데이터를 생성합니다
z = np.linspace(0, 15, 1000)
x = np.sin(z)
y = np.cos(z)
ax.plot3D(x, y, z, 'gray')
plt.show()
In [32]:
# project=3d로 설정합니다
ax = plt.axes(projection='3d')
sample_size = 100
x = np.cumsum(np.random.normal(0, 1, sample_size))
y = np.cumsum(np.random.normal(0, 1, sample_size))
z = np.cumsum(np.random.normal(0, 1, sample_size))
# marker 추가
ax.plot3D(x, y, z, alpha=0.6, marker='o')
plt.title("ax.plot")
plt.show()
3d-scatter¶
In [33]:
fig = plt.figure(figsize=(10, 5))
ax = fig.add_subplot(111, projection='3d') # Axe3D object
sample_size = 500
x = np.cumsum(np.random.normal(0, 5, sample_size))
y = np.cumsum(np.random.normal(0, 5, sample_size))
z = np.cumsum(np.random.normal(0, 5, sample_size))
ax.scatter(x, y, z, c = z, s=20, alpha=0.5, cmap='Greens')
plt.title("ax.scatter")
plt.show()
contour3D 그리기 (등고선)¶
In [34]:
x = np.linspace(-6, 6, 30)
y = np.linspace(-6, 6, 30)
x, y = np.meshgrid(x, y)
z = np.sin(np.sqrt(x**2 + y**2))
fig = plt.figure(figsize=(12, 6))
ax = plt.axes(projection='3d')
ax.contour3D(x, y, z, 20, cmap='Reds')
plt.title("ax.contour3D")
plt.show()
imshow¶
array 형식의 이미지(image) 데이터를 시각화 할 때는 imshow
를 활용합니다.
In [35]:
import matplotlib.image as mpimg
from PIL import Image
import urllib
# 샘플 이미지 다운로드
url = 'https://raw.githubusercontent.com/mwaskom/seaborn-data/master/png/img6.png'
image_data = Image.open(urllib.request.urlopen(url))
image_data
Out[35]:
In [36]:
img = np.asarray(image_data)
img[:5, :5, 0]
Out[36]:
array([[64, 61, 47, 36, 35], [68, 60, 51, 38, 40], [63, 58, 54, 48, 43], [64, 58, 50, 51, 48], [71, 62, 50, 46, 47]], dtype=uint8)
In [37]:
plt.imshow(img)
plt.show()
In [40]:
x_label = ['Math', 'Programming', 'Data Science', 'Art', 'English', 'Physics']
x = np.arange(len(x_label))
y_1 = [66, 80, 60, 50, 80, 10]
y_2 = [55, 90, 40, 60, 70, 20]
width = 0.35
fig, axes = plt.subplots()
# TODO: "Barplot에서 비교 그래프 그리기"에서 그렸던 그래프를 그리세요.
# 그래프를 이미지로 저장하기 전에 show() 함수를 호출하면 채점이 되지 않습니다.
# 넓이 설정
axes.bar(x - width/2, y_1, width, align='center', alpha=0.5)
axes.bar(x + width/2, y_2, width, align='center', alpha=0.8)
# xtick 설정
plt.xticks(x)
axes.set_xticklabels(x_label)
plt.ylabel('Number of Students')
plt.title('Subjects')
plt.legend(['john', 'peter'])
#plt.show()
# 이 아래를 수정하면 제대로 채점되지 않습니다.
plt.tight_layout()
plt.savefig('result.png')
plt.show()
반응형
'Biusiness Insight > Data Science' 카테고리의 다른 글
[Python] Seaborn을 활용한 시각화 - seaborn stats (0) | 2024.06.30 |
---|---|
[Python] Seaborn을 활용한 시각화 (0) | 2024.06.30 |
[Python] Matplotlib을 활용한 시각화 (0) | 2024.06.30 |
[Python] 데이터프레임 시각화 (0) | 2024.06.30 |
[Python] Pandas concat, merge 실습 (0) | 2024.06.30 |