매번 업데이트하고 있습니다. 


* Multiple Plot 그릴 때 (특히 legend를 같이 그리고 싶을 때)

http://stackoverflow.com/questions/5484922/secondary-axis-with-twinx-how-to-add-to-legend


* Bar chart에서 bar 마다 색을 다르게 주기

http://stackoverflow.com/questions/18973404/settting-different-bar-color-in-matplotlib-python


* Scatter Plot 에서 point 에 색을 주기 (colormap 도 같이 있음)

http://stackoverflow.com/questions/8202605/matplotlib-scatterplot-colour-as-a-function-of-a-third-variable

http://matplotlib.org/examples/pylab_examples/scatter_demo2.html


* Plot에서 error를 색으로 칠하기

http://stackoverflow.com/questions/12957582/matplotlib-plot-yerr-xerr-as-shaded-region-rather-than-error-bars


* Legend 사이즈 조절하기

http://stackoverflow.com/questions/20048352/how-to-adjust-the-size-of-matplotlib-legend-box


* 그래프 퀴퉁이에 text 넣기

http://stackoverflow.com/questions/8482588/putting-text-in-top-left-corner-of-matplotlib-plot


* Colorbar 뒤집어 그리기 (cm에 있는 colorbar)

http://stackoverflow.com/questions/3279560/invert-colormap-in-matplotlib 

(가장 많은 추천의 답이 정답...!)


* 그림 png로 저장할 때 크기 및 해상도 조절하기

http://stackoverflow.com/questions/332289/how-do-you-change-the-size-of-figures-drawn-with-matplotlib


* PolyCollection 사용하기 (Polygon을 그리고 색을 정해줄 수 있음)

http://matplotlib.org/examples/api/collections_demo.html


* Discrete color bar 만들기 (polygon 색칠할 때 색을 정해줄 경우, 이걸로 우회하여 해결... 어떻게 폴리곤마다 색을 지정해주는지는 아직 모르겠음..)

http://stackoverflow.com/questions/14777066/matplotlib-discrete-colorbar


* Discrete color bar 만들기2 -> 자신이 원하는 색으로 만드는 방법. 꽤 쉬움..

http://stackoverflow.com/questions/9707676/defining-a-discrete-colormap-for-imshow-in-matplotlib


* Axis 눈금을 동등하게 그리기

http://matplotlib.org/examples/pylab_examples/axis_equal_demo.html


* Imshow에서 square 로 plot 하기. 사실 aspect 를 조절하면 되는데, 이걸 계산해서 square로 만들어줘야 하니까... 좀 번거로움. 

http://stackoverflow.com/questions/7965743/python-matplotlib-setting-aspect-ratio



* 3D plot from data

http://stackoverflow.com/questions/4363857/matplotlib-color-in-3d-plotting-from-an-x-y-z-data-set-without-using-contour

http://stackoverflow.com/questions/12730436/matplotlib-plotting-non-uniform-data-in-3d-surface


*Scatter plot에서 point마다 label 주기

http://stackoverflow.com/questions/5147112/matplotlib-how-to-put-individual-tags-for-a-scatter-plot (Gorgeous!)

http://stackoverflow.com/questions/14432557/matplotlib-scatter-plot-with-different-text-at-each-data-point (Basic)

'Study > Computer' 카테고리의 다른 글

numpy array 잘라쓰기  (0) 2014.06.17
Python으로 n-gram 만들기  (0) 2014.05.22
위도, 경도 검색 프로그램  (0) 2014.05.09
Too many open files 에러가 로그에 남을 때  (0) 2014.04.07
py2exe로 pyQT4 코드 exe로 만들기  (0) 2014.03.13

데이터 파일이 density matrix 형태일 때 density plot 을 그리는 방법.


* 데이터파일 구조 (density matrix 형태)

1 2 3

4 5 6

7 8 9


* gnuplot 에서 그리는 방법

 >>> set pm3d map

 >>> splot './data.txt' matrix 


키워드를 입력하면 주어진 키워드의 위도와 경도를 검색하는 프로그램을 만들었다. 


가끔 필요할 때마다 프로그램 짜는게 너무 귀찮아졌다. (항상 대충 만들어서 나중에 재활용하기가 안좋더라고요.)
그래서 이번에 아주 예쁘게 만들어 필요하신 분에게 배포까지 하기로 결심했음...


Download: 

search_loc_to_lon_lat.py

프로그램의 개요는 다음과 같다.


-1: Pre-requirement

 - Python 2.x    (제작은 python 2.7에서...)

 - No additional Lib

 - Daum과 Naver의 API KEY!!! (이건 코드 안에 주석으로 자세히 설명해두었습니다.)


0. 실행 방법: python 프로그램.py  (실행 옵션은 이렇게 치면 나와요...)


 자세히...

 USAGE: python program.py -i (--input) input.txt -e (--encoding) cp949 - (--output) output.txt -s x,y (y,x)

 Default input encoding\t: utf-8

 Default output\t\t: save in result.txt

 Default output seq.\t: x\ty


1. Input

  - Input.txt 로부터 키워드를 읽어온다. 한 줄에 하나씩 키워드가 있어야 함.

예시: 

==== input.txt

인천광역시 중구청

철원군청

ㄱㄱㄱㄱㄱ

성균관대학교 자연과학캠퍼스



2. Output

  - 옵션에서 지정한 파일 이름 혹은 result.txt 로 저장

예시:

==== result.txt

#이름 x(경도) y(위도)

"인천광역시 중구청" 126.62161335 37.4738403028

"철원군청" 127.313518298 38.1469249461

ㄱㄱㄱㄱㄱ None None

"성균관대학교 자연과학캠퍼스" 126.97467286 37.2934204446


3. 특징 (별건 없지만...)

 - Input 파일의 인코딩을 지정해줄 수 있음. 그래서 운영체제 따위 가리지 않음. 인코딩 따로 변환할 필요도 없음.

 - Outputx coordinate와 y coordinate 의 순서를 정할 수 있음


4. 한계점

 - 국내용.... -.-


+ Recent posts