【发布时间】:2020-05-21 20:06:20
【问题描述】:
我正在尝试为图像上的地理坐标图制作动画,在本例中为地图的 sn-p。我设法制作了一个静态图,但无法让它动画化。我尝试使用 matplotlib 动画功能制作动画,但没有取得任何成功。我正在使用 pandas 将 csv 读入 Python 并使用 matplotlib.pyplot 进行绘图。下面是静态图的代码。
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('mydata.csv', header=0)
# find max/min, plug into a website, snip area as png and insert as plotmap
BBox = ((df.LONGITUDE.min(), df.LONGITUDE.max(),
df.LATITUDE.min(), df.LATITUDE.max()))
#read the image in, plot points over image
plotmap = "myimage.png"
truthplot = plt.imread(plotmap)
fig, ax = plt.subplots(figsize = (8,8),linewidth = 0.1)
ax.scatter(df.LONGITUDE, df.LATITUDE, zorder=1, alpha= 0.5, c='b', s=10)
plottitle = "test"
ax.set_title(plottitle)
ax.set_xlabel("Longitude")
ax.set_ylabel("Latitude")
ax.set_xlim(BBox[0], BBox[1])
ax.set_ylim(BBox[2], BBox[3])
ax.imshow(truthplot, zorder=0, extent = BBox, aspect= 'equal')
plt.show()
一些示例坐标:
LATITUDE LONGITUDE
30.112342 10.678982
29.443459 11.678997
29.334221 11.889544
28.993448 12.003847
我还是个新手;任何帮助表示赞赏。
【问题讨论】:
标签: python pandas matplotlib