In [4]:
import numpy as np
import matplotlib.tri as tri
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
In [5]:
npts = 100
x = np.random.uniform(-2, 2, npts)
y = np.random.uniform(-2, 2, npts)
z = x * np.exp(-x**2 - y**2)
ngridx = 100
ngridy = 100
xi = np.linspace(-2.2, 2.2, ngridx)
yi = np.linspace(-2.2, 2.2, ngridy)
triang = tri.Triangulation(x, y)
interpolator = tri.LinearTriInterpolator(triang, z)
Xi, Yi = np.meshgrid(xi, yi)
zi = interpolator(Xi, Yi)
plt.contour(xi, yi, zi, colors='black')
Out[5]:
<matplotlib.contour.QuadContourSet at 0x178b1237e90>
In [8]:
plt.contour(xi, yi, zi, 20, cmap='RdGy')
plt.colorbar()
Out[8]:
<matplotlib.colorbar.Colorbar at 0x178b1c8eed0>
In [9]:
plt.contourf(xi, yi, zi, 20, cmap='RdGy') # 내부 색칠
plt.colorbar()
Out[9]:
<matplotlib.colorbar.Colorbar at 0x178b1dae360>
In [ ]:
'2학년 2학기 > 데이터 사이언스 입문' 카테고리의 다른 글
[Visualization] Colormap (0) | 2024.12.02 |
---|---|
[Visualization] Regend (0) | 2024.12.02 |
[Visualization] Error Bar (0) | 2024.11.26 |
[Visualization] Scatter Plot(산점도) (0) | 2024.11.26 |
[Visualization] LinePlot (0) | 2024.11.26 |