底图上没有显示纬度网格

问题描述 投票:0回答:0

我正在尝试使用 python 绘制底图和网格。

但是纬度的网格没有显示如下。 (我是stackoverflow的初学者,所以图不直接展示)

enter image description here

代码如下

filename = 'temp.txt'
df = pd.read_csv(filename, sep = "\t")

lllon = df['lon'].min()
lllat = df['lat'].min()
urlon = df['lon'].max()
urlat = df['lat'].max()

station_names = df['sta'].to_list()

# Assign values from station information  (For now, values are assigned as altitude of each station)
values = [df.loc[df['sta'] == s][param].values[0] for s in station_names]


pad = 0.0001 
m = Basemap( projection='lcc', resolution='c', llcrnrlon=format(lllon - pad,'.4f'), llcrnrlat=format(lllat - pad/2,'.4f')
            , urcrnrlon=format(urlon + pad,'.4f'), urcrnrlat=format(urlat + pad/2,'.4f'), epsg=5186)

m.drawparallels(np.linspace(lllat, urlat, 4),
                labels=[1,0,0,0], linewidth=100,  fmt='%10.4f', zorder=53)   # draw parallels
m.drawmeridians(np.linspace(lllon, urlon, 4),
                labels=[0,0,0,1], linewidth=0.5,  fmt='%10.4f', zorder=53)   # draw meridians

文件名数据如下。

sta lon lat depth
sta1    127.235834  37.583892   3
sta2    127.236328  37.583877   11
sta3    127.236841  37.583823   13
sta4    127.236896  37.584206   16
sta5    127.236382  37.584227   14
sta6    127.235859  37.584256   13

首先,我认为它是不可见的(网格存在但由于线宽没有显示)但网格不存在

当我在不同地区使用几乎相似的代码时,它有效,但在这个地区,它不起作用。

如果您对此有所了解,请告诉我好吗?

我尝试了 dashes=[10, 10 (with other numbers)] and linewidth, large latitude range 并更改了 fmt 部分,但没有更改。

python matplotlib-basemap
© www.soinside.com 2019 - 2024. All rights reserved.