본문 바로가기

시각화/Matplotlib

(24)
Matplotlib - 그래프를 파일로 저장하기 : savefig plt.savefig(fname, dpi, facecolor, format, bbox_inches, transparent) - fname : 파일 경로나 파이썬의 유사한 객체를 나타내는 문자열 (파일명.pdf) - dpi : figure의 인치당 도트 해상도, 기본값은 100 - facecolor : edgecolor로도 설정가능하며 배경 색상을 변경함, 기본값은 흰색 - format : 명시적 파일 포맷 (png, svg, pdf...) - bbox_inches : figure에서 저장할 부분 - transparent : 그림 배경을 투명하게 지정 (True를 넘기면 된다.) 아무 옵션 없이 그냥 저장 옵션 추가 : dpi=400, bbox_inches='tight' 이는 사진의 크기를 키운 것이 아니..
Matplotlib - add_subplot : set_xticks, set_xticklabels, tick_params https://steadiness-193.tistory.com/162 Matplotlib - add_subplot 화면 분할하여 그래프를 여러 개 그리기 - axe 객체 활용 이 포스팅에선 우선 하나의 그래프를 ax 객체를 이용해서 그려본다. https://steadiness-193.tistory.com/149 Matplotlib - plt : 선그래프, xlabel, ylab.. steadiness-193.tistory.com 위 포스팅에서 설명을 했지만 추가적으로 x축에 대해서만 더 살펴보자. 기본 그래프 data = np.random.randn(100).cumsum() set_xticks : 전체 데이터 범위에 맞춰 눈금을 어디에 배치할지 지정 지금은 0부터 20씩 커진 100까지의 눈금이 있지만 ..
Matplotlib - add_subplot(2) https://steadiness-193.tistory.com/149 Matplotlib - plt : 선그래프, xlabel, ylabel, title, legend(범례) 데이터 불러오기 서울에서 경기도로 이동한 인구 데이터 값 import matplotlib.pyplot as plt 한글 폰트 문제 해결 from matplotlib import font_manager, rc font_path = 'c:/Windows/Fonts/malgun.ttf' font_na.. steadiness-193.tistory.com 위 포스팅에서 만든 sr_kk 시리즈를 이용한다. https://steadiness-193.tistory.com/162 Matplotlib - add_subplot 화면 분할하여 그래프를 ..
Matplotlib - add_subplot 화면 분할하여 그래프를 여러 개 그리기 - axe 객체 활용 이 포스팅에선 우선 하나의 그래프를 ax 객체를 이용해서 그려본다. https://steadiness-193.tistory.com/149 Matplotlib - plt : 선그래프, xlabel, ylabel, title, legend(범례) 데이터 불러오기 서울에서 경기도로 이동한 인구 데이터 값 import matplotlib.pyplot as plt 한글 폰트 문제 해결 from matplotlib import font_manager, rc font_path = 'c:/Windows/Fonts/malgun.ttf' font_na.. steadiness-193.tistory.com 위 포스팅에서 만든 sr_kk 시리즈를 이용한다. 주피터 노..
Matplotlib - plt : xlim, ylim https://steadiness-193.tistory.com/151 Matplotlib - 그래프 꾸미기 : marker, markerfacecolor, markersize, color, linewidth, linestyle https://steadiness-193.tistory.com/150 Matplotlib - plt : xticks, yticks https://steadiness-193.tistory.com/149 Matplotlib - 선그래프, x축 라벨, y축 라벨, 그래프 제목, 범례 데이터 불러오기 서울에서.. steadiness-193.tistory.com 위 포스팅에서 만든 그래프를 이용한다. 기존 그래프 xlim x축의 최솟값과 최댓값을 설정한다. plt.xlim([최솟값, 최댓값..
Matplotlib - 그래프 꾸미기 : marker, markerfacecolor, markersize, color, linewidth, linestyle https://steadiness-193.tistory.com/150 Matplotlib - plt : xticks, yticks https://steadiness-193.tistory.com/149 Matplotlib - 선그래프, x축 라벨, y축 라벨, 그래프 제목, 범례 데이터 불러오기 서울에서 경기도로 이동한 인구 데이터 값 import matplotlib.pyplot as plt 한글 폰트.. steadiness-193.tistory.com 위 포스팅에서 만든 그래프를 이용한다. 선 그래프의 꾸미기 옵션 옵션 설명 'o' 선이 아닌 점 그래프 marker 마커 모양 'o' ',' '^' '' '*' '+' 'v' '8' 's' 'p' 'h' 'D' '.' markerfacecolor 마커 배경..
Matplotlib - plt : xticks, yticks https://steadiness-193.tistory.com/149 Matplotlib - 선그래프, x축 라벨, y축 라벨, 그래프 제목, 범례 데이터 불러오기 서울에서 경기도로 이동한 인구 데이터 값 import matplotlib.pyplot as plt 한글 폰트 문제 해결 from matplotlib import font_manager, rc font_path = 'c:/Windows/Fonts/malgun.ttf' font_na.. steadiness-193.tistory.com 위 포스팅에서 만든 sr_kk 시리즈를 이용한다. sr_kk의 인덱스는 1970년부터 2018년까지인데 문자열로 되어있어 이를 정수형으로 바꿔서 그래프를 다시 그려본다. 위의 x축에 표시되는 숫자가 10년 단위로 뜨..
Matplotlib - plt : 선그래프, xlabel, ylabel, title, legend(범례) 데이터 불러오기 서울에서 경기도로 이동한 인구 데이터 값 import matplotlib.pyplot as plt 한글 폰트 문제 해결 from matplotlib import font_manager, rc font_path = 'c:/Windows/Fonts/malgun.ttf' font_name = font_manager.FontProperties(fname=font_path).get_name() rc('font', family=font_name) 선 그래프 1. plt.plot(x축 설정, y축 설정) 2. plt.plot(시리즈) 3. 시리즈.plot() 이 방법은 위 2가지 방법에 비해 x축 인덱스가 많이 생략됐다. x축 이름 plt.xlabel(이름) size와 fontsize 모두 동일한 결..