图像不包含散点

时间:2019-05-27 05:11:08

标签: python matplotlib

HY,使用以下代码,我想在地图上打印点

from gps import *
import matplotlib.pyplot as plt
import time, inspect, os

logPath = "C:\Users\Etantonio\PycharmProjects\MapShow\LOGS"
actualMapFilePath = logPath + "\Map_GPS.png"
actualFigureMapFilePath = logPath + "\FIGURE_Map_GPS.png"

# adjust these values based on your location and map, lat and long are in decimal degrees
TRX = -12.6453  # top right longitude
TRY = 46.871  # top right latitude
BLX = -12.6347  # bottom left longitude
BLY = 46.8638  # bottom left latitude

# Create Image File
pos_y = 46.865321667
pos_x = -12.640213333

# Load the mapp
im = plt.imread('map.png')
plt.imshow(im, extent=[BLX, TRX, BLY, TRY], zorder=1)

# add a point over the map
plt.scatter(x=[pos_x], y=[pos_y], s=5, c='r', zorder=2)

# OK, the point is showed on the map, perfect quality
plt.show()

# NOT OK, in the resulting file it is showed only the map not the point
plt.imsave(actualMapFilePath, im)

# OK, the point is showed on the map, but bad quality
plt.savefig(actualFigureMapFilePath, dpi=150, bbox_inches='tight', cmap="hot")

我不明白为什么点不显示在地图上

plt.imsave(actualMapFilePath, im)

谢谢安东尼奥

0 个答案:

没有答案