Notice
Recent Posts
Recent Comments
관리 메뉴

안까먹을라고 쓰는 블로그

[Python] 모두의 데이터분석 with 파이썬 - 코드2 (matplot) 본문

Language/Python

[Python] 모두의 데이터분석 with 파이썬 - 코드2 (matplot)

YawnsDuzin 2019. 10. 21. 19:29

 

반응형

https://matplotlib.org

 

Matplotlib: Python plotting — Matplotlib 3.1.1 documentation

Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. Matplotlib can be used in Python scripts, the Python and IPython shells, the Jupyter noteb

matplotlib.org

 

스터디 소스코드

import matplotlib.pyplot as plt

plt.style.use('ggplot')
plt.scatter([1,2,3,4], [10,30,20,40])
plt.show()

실행 결과

 

import matplotlib.pyplot as plt

plt.scatter([1,2,3,4], [10,30,20,40], s = [100,200,250,300])
plt.show()

실행 결과

 

import matplotlib.pyplot as plt

plt.scatter([1,2,3,4], [10,30,20,40], s = [30,60,90,120], c = ['red', 'blue', 'green', 'gold'])
plt.show()

실행 결과

 

import matplotlib.pyplot as plt
plt.scatter([1,2,3,4], [10,30,20,40], s = [30,60,90,120], c = range(4))
plt.colorbar()
plt.show()

실행 결과

 

import matplotlib.pyplot as plt
plt.scatter([1,2,3,4], [10,30,20,40], s = [30,60,90,120], c = range(4), cmap = 'jet')
plt.colorbar()
plt.show()

실행 결과

 

import matplotlib.pyplot as plt
import random

x = []
y = []
size = []

for i in range(100):
    x.append(random.randint(50, 100))
    y.append(random.randint(50, 100))
    size.append(random.randint(10, 100))
plt.scatter(x, y, s = size, cmap = 'jet', alpha = 0.7)
plt.colorbar()
plt.show()

실행 결과

반응형
Comments