Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用matplotlibtoolkit打印ISS_Matplotlib - Fatal编程技术网

使用matplotlibtoolkit打印ISS

使用matplotlibtoolkit打印ISS,matplotlib,Matplotlib,我不会经常画出国际空间站的位置。在网上找到一些代码。将其更改为python 3.5.1。 当它在while循环中运行时,它只显示一个白色屏幕。 在没有while循环的情况下运行它,并删除最后两行代码,它在世界地图上显示了国际空间站 要改变什么才能让它工作。 试着在Macbook上运行它 """ plot the ISS and update every 60 seconds""" import numpy as np from mpl_toolkits.basemap import Basema

我不会经常画出国际空间站的位置。在网上找到一些代码。将其更改为python 3.5.1。 当它在while循环中运行时,它只显示一个白色屏幕。 在没有while循环的情况下运行它,并删除最后两行代码,它在世界地图上显示了国际空间站

要改变什么才能让它工作。 试着在Macbook上运行它

""" plot the ISS and update every 60 seconds"""
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
from datetime import datetime
import time
import urllib.request
import json


def getiss():
""" call opennotify api"""
print('Get ISS data')
r=urllib.request.urlopen('http://api.open-notify.org/iss-now.json',timeout=4)
mydata = json.loads(r.read().decode(r.info().get_param('charset') or 'utf-8'))
return(mydata)

while True:
    iss = getiss()
    lat = iss['iss_position']['latitude']
    lon = iss['iss_position']['longitude']

    # miller projection
    map = Basemap(projection='mill',lon_0=0)
    # plot coastlines, draw label meridians and parallels.
    map.drawcoastlines()
    map.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0])
    map.drawmeridians(np.arange(map.lonmin,map.lonmax+30,60),labels=[0,0,0,1])
    # fill continents 'coral' (with zorder=0), color wet areas 'aqua'
    map.drawmapboundary(fill_color='aqua')
    map.fillcontinents(color='coral',lake_color='aqua')
    # shade the night areas, with alpha transparency so the 
    # map shows through. Use current time in UTC.
    date = datetime.now()
    CS=map.nightshade(date)
    plt.title('ISS Location For for %s Lat: %.2f Long: %.2f' % (date.strftime("%d %b %Y %H:%M:%S"),lat,lon))

    x,y = map(lon, lat)
    map.plot(x, y, 'bo', markersize=12)
    plt.ion()
    plt.draw()
    plt.show()
    time.sleep(60) 
    plt.clf()