Python 底图仅在左下方绘制文本或注释
Python Basemap plots text or annotate at lower left only
问题是 basemap/matplotlib 始终在左下角绘制给定文本...
我试了很多方法都没有用:
# Set up plot
fig, ax = plt.subplots(figsize=(15,15))
m1 = Basemap(projection='merc',
llcrnrlat=8.3,
urcrnrlat=53.9,
llcrnrlon=94.0,
urcrnrlon=147.6,
lat_ts=0,
resolution='c')
m1.fillcontinents(color='#191919',lake_color='#000000') # dark grey land, black lakes
m1.drawmapboundary(fill_color='#000000') # black background
m1.drawcountries(linewidth=0.1, color="w") # thin white line for country borders
m1.drawstates(linewidth=0.1, color="w")
# Plot the data
mxy = m1(new_results["Longitude"].tolist(), new_results["Latitude"].tolist())
m1.scatter(mxy[0], mxy[1], s=300,c=np.divide(new_results["SumVolume"],100000000), lw=0, alpha=1, zorder=5,cmap='Reds')
ax.annotate("blablabla", (121.597366,25.105497),color='green')
#colorbar
plt.colorbar(label=r'24H Trading-Volume in MillionK$')
plt.clim(1, 21)
plt.title("Cryptocurrency capital movement - Asia")
剧情:
有什么问题吗?
ax.annotate("blablabla", (121.597366,25.105497),color='green')
没有像我想要的那样工作。坐标 (121.597366,25.105497) 是地图上的一个点。对了,X、Y哪个都无所谓,他总是写在左下角
由于我的评论已经得到证实,我应该得出结论,问题的解决是关于坐标变换的。而问题部分的新代码是:
ax.annotate("blablabla", m1(121.597366,25.105497),color='green')
问题是 basemap/matplotlib 始终在左下角绘制给定文本...
我试了很多方法都没有用:
# Set up plot
fig, ax = plt.subplots(figsize=(15,15))
m1 = Basemap(projection='merc',
llcrnrlat=8.3,
urcrnrlat=53.9,
llcrnrlon=94.0,
urcrnrlon=147.6,
lat_ts=0,
resolution='c')
m1.fillcontinents(color='#191919',lake_color='#000000') # dark grey land, black lakes
m1.drawmapboundary(fill_color='#000000') # black background
m1.drawcountries(linewidth=0.1, color="w") # thin white line for country borders
m1.drawstates(linewidth=0.1, color="w")
# Plot the data
mxy = m1(new_results["Longitude"].tolist(), new_results["Latitude"].tolist())
m1.scatter(mxy[0], mxy[1], s=300,c=np.divide(new_results["SumVolume"],100000000), lw=0, alpha=1, zorder=5,cmap='Reds')
ax.annotate("blablabla", (121.597366,25.105497),color='green')
#colorbar
plt.colorbar(label=r'24H Trading-Volume in MillionK$')
plt.clim(1, 21)
plt.title("Cryptocurrency capital movement - Asia")
剧情:
有什么问题吗?
ax.annotate("blablabla", (121.597366,25.105497),color='green')
没有像我想要的那样工作。坐标 (121.597366,25.105497) 是地图上的一个点。对了,X、Y哪个都无所谓,他总是写在左下角
由于我的评论已经得到证实,我应该得出结论,问题的解决是关于坐标变换的。而问题部分的新代码是:
ax.annotate("blablabla", m1(121.597366,25.105497),color='green')