糟糕,利用Matplotlib绘图没救了

python利用Matplotlib绘图时,画出来的图变这样了

img

代码是这样的,

import math
import pandas as pd
import matplotlib.pyplot as plt

# Haversine公式函数
def haversine(lon1, lat1, lon2, lat2):
    """
    Calculate the great circle distance between two points 
    on the earth (specified in decimal degrees)
    """
    # 将十进制度数转化为弧度
    lon1, lat1, lon2, lat2 = map(math.radians, [lon1, lat1, lon2, lat2])

    # Haversine公式
    dlon = lon2 - lon1 
    dlat = lat2 - lat1 
    a = math.sin(dlat/2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon/2)**2
    c = 2 * math.asin(math.sqrt(a)) 
    r = 6371 # 地球平均半径,单位为公里
    return c * r * 1000

# 读取数据
runway_data = pd.read_csv('runway_data.csv', dtype={'runway_no': str})
taxiway_data = pd.read_csv('taxiway_data.csv', dtype={'taxiway_no': str})
apron_data = pd.read_csv('apron_data.csv', dtype={'apron_no': str})

from pylab import mpl

# 设置中文显示字体
mpl.rcParams["font.sans-serif"] = ["SimHei"]
# 设置正常显示符号
mpl.rcParams["axes.unicode_minus"] = False

# 画机场滑行路径拓扑图
plt.figure(figsize=(10, 10))
for i, runway in runway_data.iterrows():
    start_lon, start_lat = runway['start_lon'], runway['start_lat']
    end_lon, end_lat = runway['end_lon'], runway['end_lat']
    plt.plot([start_lon, end_lon], [start_lat, end_lat], linewidth=runway['width']*0.0003+0.3, color='b')
    plt.text((start_lon+end_lon)/2, (start_lat+end_lat)/2, runway['runway_no'] + ' ' + str(runway['length']) + 'm', ha='center', va='center', fontsize=10)
for i, taxiway in taxiway_data.iterrows():
    start_lon, start_lat = taxiway['start_lon'], taxiway['start_lat']
    end_lon, end_lat = taxiway['end_lon'], taxiway['end_lat']
    length = haversine(start_lon, start_lat, end_lon, end_lat)
    plt.plot([start_lon, end_lon], [start_lat, end_lat], linewidth=length*0.0003+0.1, color='g')
    plt.text((start_lon+end_lon)/2, (start_lat+end_lat)/2, taxiway['taxiway_no'] + ' ' + str(int(length)) + 'm', ha='center', va='center', fontsize=8)
for i, apron in apron_data.iterrows():
    plt.plot(apron['apron_lon'], apron['apron_lat'], marker='o', markersize=5, color='r')
    plt.text(apron['apron_lon']+0.0001, apron['apron_lat']+0.0001, apron['apron_no'], ha='left', va='bottom', fontsize=6)
plt.xlabel('经度', fontsize=12)
plt.ylabel('纬度', fontsize=12)
plt.title('长沙黄花机场滑行路径拓扑图', fontsize=16)
plt.show()

它为什么不画图呢

数据发给我,我跑一下试试