February 01, 2022

How to print coordinates on the screen with Python

 


 

import matplotlib.pyplot as plt

x = [100, 500, 100, 500 ]
y = [100, 500, 500, 100 ]

plt.fill(x, y, color="lightgray")
plt.show()

 

Using Python's matplotlib module, displaing coordinates is simple. However, the system must support GUI.

파이썬의 matplotlib 모듈을 이용하면 간단히 좌표를 표시할 수 있다. 다만, 시스템이 GUI를 지원해야 한다.

 

Make two lists to store X, Y coordinates. And enter it in the fill() function. Then, the coordinates are automatically represented by the pair. If you specify a color in the color option, you can paint the interior of the coordinate.

x, y 좌표는 각각의 리스트로 생성한다. 이를 fill() 함수에 입력하면 자동으로 쌍을 지어 좌표가 표현된다. color 옵션에 색을 지정하면 좌표 내부 공간을 칠할 수도 있다.