본문 바로가기

Data Visualization16

[Seaborn] 12. lineplot [Seaborn] 12. lineplot 사용할 데이터import pandas as pdimport numpy as np# 데이터 생성np.random.seed(42)# 기본 데이터 구조 생성months = ['3월', '4월', '5월', '6월', '7월']classes = ['A반', 'B반', 'C반', 'D반']data = []for class_name in classes: # 기본 성적 수준 설정 (반마다 다르게) base_score = np.random.normal(75, 5) # 시간에 따른 변화 추가 for month in months: # 약간의 상승 트렌드와 노이즈 추가 trend = months.index(month) * 2 #.. 2024. 11. 15.
[Seaborn] 11. swarmpplot [Seaborn] 11. swarmpplot1. stripplot 기본sns.swarmplot(data=df)분포가 넘치면 위쪽에 limit가 걸린다2. 컬럼 입력sns.swarmplot(data=df, x='반', y='국어')컬럼 입력하면 범주형 구분해서 y값 분포를 보여준다.3. 그룹화sns.swarmplot( # 기본 데이터 설정: 데이터프레임 / X축 / Y축 / 색상구분 data=df, x='반', y='국어', hue='성별', # 스타일 설정: 점크기 / 투명도 / 팔레트 size=4, alpha=0.6, palette='muted')4. swarm + violin# Violin Plot + Swarm Plot 결합# 1. 바이올린플롯 기본sns.violinpl.. 2024. 11. 15.
[Seaborn] 10. stripplot [Seaborn] 10. stripplot  1. stripplot 기본sns.stripplot(data=df)데이터만 넣으면 범주형으로 나뉜다.2. 컬럼 입력sns.stripplot(data=df, x='반', y='국어')컬럼 입력하면 범주형 구분해서 y값 분포를 보여준다.3. 그룹화sns.stripplot( # 기본 데이터 설정: 데이터프레임 / X축 / Y축 / 색상구분 data=df, x='반', y='국어', hue='성별', # 스타일 설정: 점크기 / 투명도 / 팔레트 / 지터량 size=4, alpha=0.5, palette='Set2', jitter=0.2)jitter를 추가해서 데이터가 좌우로 산포되어있는 것을 조정할 수 있다.0.2도 넓다 싶으면 줄이기... 2024. 11. 15.
[Seaborn] 9. countplot [Seaborn] 9. countplotseaborn countplot사용할 데이터import numpy as npimport pandas as pdn = 1000# 기본 능력치 생성 (학생들의 전반적인 학습 능력)base_ability = np.random.normal(0, 1, size=n)physical_ability = np.random.normal(0, 1, size=n) # 체육 능력 추가# 과목별 점수 생성국어 = 75 + 10 * (0.7 * base_ability + 0.3 * np.random.normal(0, 1, size=n))영어 = 72 + 12 * (0.6 * base_ability + 0.4 * np.random.normal(0, 1, size=n))수학 = 70 + 15 .. 2024. 11. 15.