오늘의 인기 글
최근 글
최근 댓글
Today
Total
05-17 10:18
관리 메뉴

우노

[Python] Matplotlib Color 종류 본문

Language/Python

[Python] Matplotlib Color 종류

운호(Noah) 2020. 12. 1. 12:42
  • Matplotlib에서 그래프를 plot,scatter 등으로 표현 할 때, 파라미터를 통해 점의 색깔(color)를 지정할 수 있다.

Color 종류

예제 코드

  • plot

      from matplotlib import pyplot as plt
    
      # x,y 축 데이터
      years = [1950, 1960, 1970, 1980, 1990, 2000, 2010]
      gdp = [300.2, 543.3, 1075.9, 2862.5, 5979.6, 10289.7, 14958.3]
    
      # 표 내부 설정
      plt.plot(years, gdp, color='darkmagenta', marker='o', linestyle='solid')
    
      # 표 외부 설정
      plt.title("Nominal GDP")
      plt.ylabel("Billions of $")
      plt.xlabel("Years")
    
      # 표 그리기
      plt.show()

  • scatter

      from matplotlib import pyplot as plt
    
      # x,y 축 데이터
      years = [1950, 1960, 1970, 1980, 1990, 2000, 2010]
      gdp = [300.2, 543.3, 1075.9, 2862.5, 5979.6, 10289.7, 14958.3]
    
      # 표 내부 설정
      plt.scatter(years, gdp, marker='^', color='limegreen')
    
      # 표 외부 설정
      plt.title("Nominal GDP")
      plt.ylabel("Billions of $")
      plt.xlabel("Years")
    
      # 표 그리기
      plt.show()

참고

Comments