python - matplotlib 在 Python 3.6.5 上不显示任何带有 xarray 的 plot() 的绘图窗口
问题描述
我试图在 Python 3.6.5 上使用 matplotlib 和 xarray 进行绘图。
我的代码实际上来自xarray 文档:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import xarray as xr
airtemps = xr.tutorial.open_dataset('air_temperature')
print(airtemps)
air = airtemps.air - 273.15
air.attrs = airtemps.air.attrs
air.attrs['units'] = 'deg C'
air1d = air.isel(lat=10, lon=10)
air1d.plot() # using xarray.DataArray's plot()
当我运行代码(在 virturlenv 中)时,它没有显示任何绘图窗口,也没有引发错误。
解决方案
我的错误我忘了在最后调用 plt.show() 。
推荐阅读
- javascript - 验证数据然后返回解析?
- numpy - numpy 掩码覆盖另一个掩码
- c# - Azure 耐用功能。编排产生了许多不需要的活动
- c# - MVC 身份 cookie 跨子域进行身份验证
- angular - 防止 PrimeNg 中的 NodeExpand 事件
- c++ - 如何传递大小未知的 std::array?在 C++ 中
- apache-kafka - 使用 Kafka Streams 在输出中设置时间戳
- gitlab - 将外部文件添加到本地存储库后 git push 出错
- angular - 使用角度4以数组格式获取多个复选框值
- c# - 在 Windows 启动时自动以管理员身份运行