import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches
import numpy as np
#plt.rcParams["font.family"]="SimHei" #正常显示中文
def drawBoundary(ax, boundary, **kw):
"""
绘制地理坐标区域
:param ax: 绘制的坐标轴
:param boundary: 待绘制的地理区域(必需为四角标依次存储)
"""
verts = list(boundary)
verts.append(verts[0])
codes = [
Path.MOVETO,
Path.LINETO,
Path.LINETO,
Path.LINETO,
Path.CLOSEPOLY
]
path = Path(verts, codes)
patch = patches.PathPatch(path, facecolor='g', alpha=0.05)
ax.add_patch(patch)
#第一步创建图形画板和图
fig, ax = plt.subplots()
boundary = [
(34.914937, 112.913792), # 矩形左下角的坐标(left,bottom)
(34.816718, 113.460402), # 矩形左上角的坐标(left,top)
(34.375733, 113.342728), # 矩形右上角的坐标(right,top)
(34.473672, 112.799020) ]# 矩形右下角的坐标(right, bottom)] # 封闭到起点
params = 'g-'
#绘制一张影像的地理边界
drawBoundary( ax, boundary,linestyle = '--',linewidth = 1,label='boundary',color = 'b')
tie_ponits= np.array([[34.477728 , 112.972514, 466.250588],
[34.475660,112.977638 ,443.428995],
[34.472156 ,113.011141, 440.242173]])
ax.scatter(tie_ponits[:,0],tie_ponits[:,1],label='tie_points',color = 'y',marker = '*', s=20)
ax.legend(loc=4,fontsize=8)
#图的参数设置
ax.set_title("Layout",fontsize=12,verticalalignment="baseline")#标题(表头)
plt.tick_params()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
#ax.spines['top'].set_color('none')
#ax.tick_params(labelsize='small')
ax.axis('equal')
plt.show()