2
緯度と経度の座標に基づいて、グローバルマップ上のデータベース(sqliteとbasemapモジュール)からプロットポイント(空港)を試します。しかし、私のコードは、ポイントとマップと別の数字としてプロットし、ランタイムエラーと言う:RuntimeError:単一のアーティストを複数のFigureに配置することはできません。私は私が間違っているのかわからないです:pythonのベースマップに点を描画するとランタイムエラーが発生する
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import sqlite3
conn = sqlite3.connect("flights.db")
cur = conn.cursor()
cur.execute("select * from airlines limit 5;")
results = cur.fetchall()
print(results)
coords = cur.execute(""" select cast(longitude as float), \
cast(latitude as float) from airports;""" \
).fetchall()
m = Basemap(projection = 'merc', llcrnrlat =-80, urcrnrlat = 80, \
llcrnrlon = -180, urcrnrlon = 180, lat_ts = 20, \
resolution = 'c')
m.drawcoastlines()
m.drawmapboundary()
x, y = m([l[0] for l in coords], [l[1] for l in coords])
m.scatter(x, y, 1, marker='o', color='red')
私が手にエラーは以下の通りです:
RuntimeError: Can not put single artist in more than one figure
としての最後の行のデータセット「flights.db」は、ここにあります:https://www.dropbox.com/s/a2wax843eniq12g/flights.db?dl=0 – nigus21