有没有办法改进这个交互式 matplotlib/cartopy 脚本的渲染?
请先安装 ipympl https://github.com/matplotlib/ipympl
我还没有找到如何在不实例化新图形的情况下更改中心经度和纬度。
当单击鼠标左键并选择新的投影中心时,此脚本缺乏流动性。我正在寻找https://twojs.org/examples/misc_controls_trackball中的轨迹球行为。
欢迎任何帮助/建议。
%matplotlib widget
import numpy as np
import matplotlib.pyplot as plt
import cartopy
import cartopy.crs as ccrs
fig = plt.figure(figsize=(10,6), layout='constrained')
proj0 = ccrs.PlateCarree()
proj1 = ccrs.Orthographic(0, 80)
ax1 = fig.add_subplot(1, 1, 1, projection=proj1)
ax1.coastlines()
ax1.gridlines(xlocs=np.arange(-180,180,10), ylocs=np.arange(-80,90,10))
ax1.set_global()
def onpress(event):
global proj1
if event.button == 1:
lon, lat = proj0.transform_point(event.xdata, event.ydata, src_crs=proj1)
proj1 = ccrs.Orthographic(lon, lat)
ax1 = fig.add_subplot(1, 1, 1, projection=proj1)
ax1.coastlines()
ax1.gridlines(xlocs=np.arange(-180,180,10), ylocs=np.arange(-80,90,10))
ax1.set_global()
plt.draw()
fig.canvas.mpl_connect('button_press_event', onpress)
plt.show()
Run Code Online (Sandbox Code Playgroud)
我很难理解为什么bash -e选项退出此脚本.只有在计算的表达式给出时才会发生0:
#!/bin/bash
set -ex
table_year=( 1979 1982 1980 1993 1995 )
year=$1
let indice=year-1
real_year=${table_year[$indice]}
echo OK $real_year
Run Code Online (Sandbox Code Playgroud)
是的还可以:
./bash_test_array 2
Run Code Online (Sandbox Code Playgroud)
但不是在:
./bash_test_array 1
Run Code Online (Sandbox Code Playgroud)
indice这种情况等于0.为什么-e选项导致退出?