ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Grid type, 선/면 추가
    CS 공부/Data Visualization 2023. 3. 27. 13:51

    Grid type


    • 두 변수의 합이 중요하면 X+Y=C를 사용한 Grid
      • 성적데이터
    # x+y가 1보다 작으면 파랑, 크면 회색
    ax.scatter(x, y, s=150, 
               c=['#1ABDE9' if xx+yy < 1.0 else 'darkgray' for xx, yy in zip(x, y)],
               linewidth=1.5,
               edgecolor='black', zorder=10)
    • 비율이 중요하면 Y=CX를 사용한 Grid
      •  가파를 수록 Y/X 가 커짐
    # y/x가 1보다 크면 파랑 작으면 회색
    ax.scatter(x, y, s=150, 
               c=['#1ABDE9' if yy/xx >= 1.0 else 'darkgray' for xx, yy in zip(x, y)],
               linewidth=1.5,
               edgecolor='black', zorder=10)
    • 두 변수의 곱이 중요하면 (X-X')2+(Y-Y')2=C를 사용한 Grid
      • 동심원을 사용
      • 한 데이터에서 특정 범위의 데이터
    #원의 반지름
    rs = np.linspace(0.1, 0.8, 8, endpoint=True)
    
    for r in rs:
        xx = r*np.cos(np.linspace(0, 2*np.pi, 100))
        yy = r*np.sin(np.linspace(0, 2*np.pi, 100))
        ax.plot(xx+x[2], yy+y[2], linestyle='--', color='gray', alpha=0.5, linewidth=1)

     

    선/면/변 추가, 테마(Theme)


    • axvline(): y축이랑 평행한 선
    • axhline(): x축이랑 평행한 선
    ax.axvline(0, color='red',linestyle='--')
    ax.axhline(0, color='green',linestyle='--')

     

    • axvspan(): y축이랑 평행한 면
    • axhspan(): x축이랑 평행한 면
    ax.axvspan(0,0.5, color='red',linestyle='', zorder=0, alpha=0.3) # 0~0.5까지 채우기
    ax.axhspan(0,0.5, color='green',linestyle='--', zorder=0, alpha=0.3)

     

    • set_visible: 변이 보이게 안보이게
    • set_linewidth: 변 두께
    • set_position: 변 위치 옮기기
    ax.spines['left'].set_position('center')
    ax.spines['bottom'].set_position('center')

     

    mpl.rc (matplot library의  Runtime Configuration Parameters)
    plt.rcParams['lines.linewidth'] = 2 #선의 default두께를 2로 변경
    #=mpl.rcParams['lines.linewidth'] = 2
    plt.rc('lines', linewidth=2, linestyle=':')
    
    plt.rcParams.update(plt.rcParamsDefault)

     

    theme
    mpl.style.use('seaborn')
    #['Solarize_Light2', '_classic_test_patch', '_mpl-gallery', '_mpl-gallery-nogrid', 'bmh', 'classic', 'dark_background', 'fast', 'fivethirtyeight', 'ggplot', 'grayscale', 'seaborn-v0_8', 'seaborn-v0_8-bright', 'seaborn-v0_8-colorblind', 'seaborn-v0_8-dark', 'seaborn-v0_8-dark-palette', 'seaborn-v0_8-darkgrid', 'seaborn-v0_8-deep', 'seaborn-v0_8-muted', 'seaborn-v0_8-notebook', 'seaborn-v0_8-paper', 'seaborn-v0_8-pastel', 'seaborn-v0_8-poster', 'seaborn-v0_8-talk', 'seaborn-v0_8-ticks', 'seaborn-v0_8-white', 'seaborn-v0_8-whitegrid', 'tableau-colorblind10']

    'CS 공부 > Data Visualization' 카테고리의 다른 글

    Polar Plot, Radar Plot (극좌표계)  (0) 2023.03.31
    Seaborn  (0) 2023.03.27
    Matplotlib 시각화 요소 (Text, Color, Facet)  (0) 2023.03.27
    Scatter plot  (0) 2023.03.26
    Line plot  (0) 2023.03.26
Designed by Tistory.