일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- PySpark
- SQL
- 파이썬
- gas
- list
- hive
- Google Spreadsheet
- matplotlib
- c#
- Apache
- array
- django
- GIT
- string
- numpy
- dataframe
- Redshift
- Kotlin
- math
- Mac
- google apps script
- Github
- PANDAS
- Google Excel
- Python
- Java
- PostgreSQL
- Tkinter
- Excel
- Today
- Total
목록Python (379)
달나라 노트
matplotlib는 굉장히 재미있는 기능들을 제공하는데 그 중에선 image 파일을 읽어서 그래프로 나타내주는 기능을 제공합니다. 제가 이전에 먹었던 녹차빙수 사진을 한번 matplotlib를 이용해서 그래프 위에 나타내보겠습니다. import matplotlib.pyplot as plt import matplotlib.image as img img_test = img.imread('greentea_ice_flakes.png') plt.imshow(img_test) plt.show() directory 구조는 위와 같습니다. pyplot.py 파일에 위 예시코드가 적혀있으며 greentea_ice_flakes.png 파일이 바로 제가 먹었던 녹차빙수 사진입니다. - img_test = img.imrea..
matplotlib에는 imshow라는 method가 있는데 이 method는 array의 값들을 색으로 환산해 이미지의 형태로 보여줍니다. import numpy as np import matplotlib.pyplot as plt arr_test = np.array( [ # 1차 array [0, 1, 0], # 2차 array [1, 0, 1], [0, 1, 0], ] ) plt.imshow(arr_test) plt.show() 위 예시는 2차원 array를 imshow에 적용한 것입니다. 그 결과는 다음과 같습니다. 체스판 형태의 이미지가 나왔죠. 지금부터 왜 위처럼 된건지 알아봅시다. 일단 사용된 array를 보면 2차원이며 다음과 같습니다. [[0 1 0] [1 0 1] [0 1 0]] imsh..
matplotlib에서 그래프를 그리는 방법은 아래 링크를 참고하면 됩니다. https://cosmosproject.tistory.com/341 이번에는 그린 그래프를 이미지 파일로 생성해볼건데 savefig method를 사용할 것입니다. import matplotlib.pyplot as plt list_x_values = [1, 2, 3, 4, 5] list_y_values = [10, 30, 15, 20, 5] plt.figure(linewidth=5) plt.plot(list_x_values, list_y_values, color='skyblue', marker='o', markerfacecolor='blue', markersize=12) plt.title('Test graph') plt.xlab..
numpy의 min, max method는 각각 주어진 값들 중 최소값, 최대값을 return합니다. import numpy as np arr_test = np.array([1, 2, 3, 4, 5]) print(arr_test) print(np.min(arr_test)) print(np.max(arr_test)) -- Result [1 2 3 4 5] 1 5 arr_test에서 각각 최소값, 최대값이 return됩니다. import numpy as np arr_test = np.array( [ # 1차 array [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15] # 2차 array ] ) print(arr_test) print(np.min(arr_tes..