通过使用ax.axhline& ax.axvline我可以这样绘制网格网络显示:
By using ax.axhline & ax.axvline I can plot the grid network shows like this:
i4.tietuku/e90652c9a56b5e61.png
代码在这里转载:
lon_grid = np.linspace(113.5,115.49,36) lat_grid = np.linspace(37.40,38.78,30) lon_grid,lat_grid = np.linspace(xc1,xc2,36), np.linspace(yc1,yc2,30) for i in range(0,len(lon_grid),1): ax.axvline(x=lon_grid[i], linestyle='-', color='black', linewidth=0.75, zorder=3) for i in range(0,len(lat_grid),1): ax.axhline(y=lat_grid[i], linestyle='-', color='black', linewidth=0.75, zorder=3)这是我的问题
我可以使用pcolor/pcolrmesh绘制网格的轮廓
Here is my question
Can I use pcolor/pcolrmesh to just draw the outline of the grid
推荐答案我会使用 ax.grid 代替.要控制网格线的位置,您可以设置刻度线的位置,例如:
I would use ax.grid for this instead. To control the positions of the grid lines you could set the positions of the ticks, e.g.:
fig, ax = plt.subplots(1, 1) ax.grid(True, which='minor', axis='both', linestyle='-', color='k') ax.set_xticks(lon_grid, minor=True) ax.set_yticks(lat_grid, minor=True) ax.set_xlim(lon_grid[0], lon_grid[-1]) ax.set_ylim(lat_grid[0], lat_grid[-1])
如果您真的想使用ax.pcolor或ax.pcolormesh,则可以将facecolor参数设置为'none',将edgecolor参数设置为'k':
If you really want to use ax.pcolor or ax.pcolormesh instead, you could set the facecolor parameter to 'none' and the edgecolor parameter to 'k':
fig, ax = plt.subplots(1, 1) x, y = np.meshgrid(lon_grid, lat_grid) c = np.ones_like(x) ax.pcolor(x, y, c, facecolor='none', edgecolor='k') ax.set_xlim(lon_grid[0], lon_grid[-1]) ax.set_ylim(lat_grid[0], lat_grid[-1])
这是一个非常值得怀疑的黑客.
This is a very questionable hack, though.
更多推荐
如何仅使用pcolor/pcolormesh绘制网格线
发布评论