mplsaple在Jupyter笔记本中与“%matplotlib inline”模式配合使用非常好,但是在启用“%matplotilib Notebook”模式时,单元格和映射之间会有大量空白。这能避免吗?在
代码:
import matplotlib.pyplot as plt
import mplleaflet
%matplotlib notebook
#some latitudes bracketing seattle
lats = [47.5062,47.7062]
#longitude
lons = [-122.3321]*len(lats)
fig,ax=plt.subplots(figsize=(8,8))
ax.scatter(lons, lats, alpha=0) #invisible data points, just to scale the map
mplleaflet.display(fig=fig)
输出如下:
问题是有一个图形被创建了,它应该显示在笔记本上。但是,您不希望将mplseplayer图形显示为与
%matplotlib notebook
后端的交互图形。在一种想法是不要使用
%matplotlib notebook
,这样放置图形mplseplayer图形的区域不会被未使用的图形填充。在或者使用
%%capture
,以便在使用%matplotlib notebook
时抑制输出。然后在新的未捕获单元格中调用mplleaflet.display
:相关问题 更多 >
编程相关推荐