본문 바로가기

분류 전체보기273

Seaborn : relplot (hue,style,col,size) hue hue는 색깔로 구분 hue에다가 object뿐만 아니라 수치(정수,소수)도 넣을수있다 style style는 marker의 형태로 구분. 작아서 안보이는데 Adelie는 'O' 모양 Chinstrap은 'ㅁ' 모양 Gentoo는 'x' 모양 hue랑 style을 동시에 보면 col size size로 marker의 크기를 조절한다 Gentoo애들이 기본적으로 체중이 나가고 bill_depth가 낮고 상관관계가 있는편. Adelie애들이 bill_length가 낮구나 bill_depth는 높은편 Chinstrap이 bill_length도 높고 bill_depth도 높은편 2022. 7. 18.
Seaborn : sns.set(font_scale=2) 폰트 규모 조정 sms.set(font_scale=2)는 전역설정이다. 계속 실행하면 사이즈가 갈수록 커진다. 그러므로 한번만 실행하고 주석처리 해야된다. 2022. 7. 18.
matplotlib bar : stateless방식 골떄리는게 plot의 매개변수는 rotation이라고하면 안되고 rot라고 해야되는데, set_ylabel 매개변수는 rotation이라고해야되고 rot라고하면 안된다. 복잡하다 참.. plt.figure(figsize=(15,7)) plt.style.use('ggplot') ax = df2.plot(kind='bar', rot=0, figsize=(16,8), ylim=[0, 3500] , title='quantity by prd type, size', stacked=True) ax.set_ylabel('sales_quantity') for c in ax.containers: labels = [v.get_height() if v.get_height() > 0 else '' for v in c] ax.b.. 2022. 7. 17.
★Matplotlib 매개변수 총정리 - stateless(ax.) ax.set_title('막대그래프', color='white', loc='left') ax.legend(bbox_to_anchor=(1.15, 1), fontsize=15) ax.set_ylabel('sales_quantity', rotation=45) xticks, yticks 1) #x축 tick기준 ax.set_xticks([10, 20, 30, 40]) #x축 tick명칭변경 및 폰트크기 설정 ax.set_xticklabels(['갑', '을', '병','정'], fontsize=15) #fontsize 조절만 하는게 안됨. 리스트로 된 범위(ex:[1, 2, 3])를 적어야만 작동이 됨 2) _, ylabels = plt.yticks() _, xlabels = plt.xticks() ax.se.. 2022. 7. 17.
df.plot 매개변수 정리사이트 https://pandas.pydata.org/pandas-docs/version/0.22/generated/pandas.DataFrame.plot.html pandas.DataFrame.plot — pandas 0.22.0 documentation Parameters:data : DataFrame x : label or position, default None y : label or position, default None Allows plotting of one column versus another kind : str ‘line’ : line plot (default) ‘bar’ : vertical bar plot ‘barh’ : horizontal bar plot ‘h pandas.pydata.org 2022. 7. 17.
★Matplotlib 매개변수 총정리 - stateful #스타일설정 plt.style.use('fivethirtyeight') plt.figure(figsize=(15, 7)) plt.bar(x리스트, y리스트, width=0.5, edgecolor='black' plt.xlabel('명칭', labelpad = 숫자, fontweight='bold', fontsize=15) -plt.xlabel(fontsize=15)하면 에러. plt.xlabel('X축', fontsize=15) 이런식으로 명칭을 적어줘야 작동됨 plt.ylabel 동일 labelpad = xlabel이 그래프와 얼마나 떨어져있는지 plt.xticks(rotation=45, fontweight='bold' 2022. 7. 17.
DataFrame : object에서 ,(콤마) 지우고 integer로 바꾸기 데이터를 보면 ,가 적혀있는 object라서 데이터를 다루는데 제한이 좀 있다. df_m.iloc[0] = df_m.iloc[0].str.replace(',','').astype(int) 첫번째 행은 integer로 바뀌었다 열을 바꾸고 싶으면? (이제부터 데이터프레임을 df_m 대신 그냥 df라고 하겠습니다) 전체바꾸는법은 아직.. 찾고있는데 잘 모르겠습니다 ?? 2022. 7. 17.
matplotlib : 막대그래프와 꺾은선그래프 동시에 그리기(twinx) https://www.youtube.com/watch?v=PjhlUzp_cU0 나도코딩 데이터분석 마지막파트 여기서 배운것들을 토대로 좀 더 찾아서 추가함 stateless 방식 ax1.legend(bbox_to_anchor=(1, 0.9),fontsize=18) - legend 상세한 위치설정 ax1.yaxis.set_label_coords(0, 1) - y축label 상세한 위치설정 ax1과 ax2 둘다 legend를 띄우면 겹쳐있어서 ax1(출생아 수)의 legend위치를 바꿨다 ax2 = ax1.twinx() 뜻 : ax2는 ax1와 같은 축을 공유한다. fig, ax1 = plt.subplots(figsize=(12,7)) ax1.bar(df.index, df['출생아 수'], label='출생.. 2022. 7. 16.