데이터/아나콘다(jupyter lab)
차트 그리기
무한경쟁시대
2021. 11. 28. 12:14
import numpy as np #앨리어스를 np로 쓰는게 암묵적 규칙 밑에도 동일
import pandas as pd
import matplotlib
변수 df와 변수 seri에 데이터를 셋팅해준 뒤
name=['홍길동','양상욱','정인우','김세하','박경미']
kor=[50,70,80,75,60]
math=[70,85,80,95,90]
data={'name':name, 'kor':kor, 'math':math}
df=pd.DataFrame(data)
df
seri=pd.Series(np.random.rand(10))
seri
seri.plot()//심플한 꺽은선그래프 나옴
matplotlib.style.use("ggplot")#matplotlib의 ggplot 스타일 적용시키면 격자가 나옴
seri.plot()
컬럼이 한개인경우 원형그래프 만들 수 있다.
seri.plot(kind='pie')
#kind 명령:bar area, pie, barh
df.plot(kind='area', stacked=False)
seri2=pd.Series(np.random.rand(5), index=["a","b","c","d","e"], name="series")
seri2=plot(kind="pie", autopct="%.2f", fontsize=20, figsize=(8,5))