본문 바로가기

Pyhton/matplotlib6

Day38_Python(14)_Pm dataFramePlotEx1import numpy as npimport pandas as pdimport matplotlib.pyplot as pltnp.random.seed(777)frame = pd.DataFrame(np.random.rand(5,3), index=['customer1','customer2','customer3','customer4','customer5'], columns=['metric1','metric2','metric3'])print(frame)fig, (ax1, ax2) = plt.subplots(1,2, figsize=(10,7))frame.plot(kind='bar', ax=ax1, alpha=0.75.. 2025. 10. 2.
Day38_Python(14)_Am boxPlotEx1import numpy as npimport matplotlib.pyplot as plt#가장 기본적인 형태# data = np.random.randn(10000) #randn종모양 형태의 그래프# plt.boxplot(data)# plt.show()N = 500normal1 = np.random.normal(loc=100, scale=15, size=N)normal2 = np.random.normal(loc=88, scale=30, size=N)fig=plt.figure(figsize=(8,8))ax1 = fig.add_subplot(111)ax1.boxplot([normal1, normal2], labels=['normal1', 'normal2'], .. 2025. 10. 2.
Day37_Python(13)_Pm barEx1import matplotlib.pyplot as pltplt.rc('font', family = 'Malgun Gothic')customer = ['김길동','홍길동','최길동','이길동','오길동']customer_index = range(len(customer))y_data = [120, 90, 200, 110, 230]fig=plt.figure(figsize=(6,4))ax1 = fig.add_subplot((111))ax1.bar(customer_index, y_data, color='darkblue')plt.xticks(customer_index, customer)plt.xlabel('고객 이름')plt.ylabel('수요')plt.show()wonen_pop = [5,39,45,2.. 2025. 10. 1.
Day37_Python(13)_Am scatterEx1import matplotlib.pyplot as pltimport numpy as npdataA = np.random.randn(100,2)#x 포인트, y 포인트 설정print(dataA)dataA += np.array([-1, -1])dataB = np.random.randn(100,2)dataB += np.array([1,1])plt.scatter(dataA[:,0], dataA[:,1], color='0.25') #색을 숫자로도 가능m 0 = 블랙, 1= 흰색plt.scatter(dataB[:,0], dataB[:,1], color='0.75', edgecolors='r') #테두리색 설정가능plt.show() import pandas as pdimport matplo.. 2025. 10. 1.
Day36_Python(12)_Pm mplibEx10import matplotlib.pyplot as pltimport pandas as pddata =pd.read_excel('fine_dust.xlsx', index_col='area')print(data)data2018 = data[2018]print(data2018) #시리즈객체plt.figure(figsize=(15, 4))plt.plot(data2018, color='lightblue', marker='o')plt.xlabel('area')plt.ylabel('2018 fine dust line graph')plt.grid(True)plt.show() plt.figure(figsize=(15, 4))for year in range(2016, 2020): .. 2025. 9. 30.
Day36_Python(12)_Am 시각화mplibEx1import matplotlib.pyplot as plt# plt.title('plotEx1')# plt.plot([1,4,8,14])# plt.show()## plt.title('plotEx1')# plt.plot([10,20,30,40], [1,4,8,14])# plt.show()# x = range(100)# y = [x**2 for x in x]# plt.plot(x,y)# plt.show()# import numpy as np# x = np.linspace(0, 2*np.pi, 100)# y = np.sin(x)# plt.plot(x,y)# plt.show()# plt.plot([10,20,30,40], [1,4,9,18], '--sr')# plt.show()plt.plot(.. 2025. 9. 30.