如何在 Matplotlib 中配置 Qt4Agg 后端的行为?


若要配置后端的行为,我们可以使用 matplotlib.rcParams['backend'] 和新的后端名称。

步骤

  • 使用 get_backend() 方法获取后端名称。

  • 使用 matplotlib.rcParams 覆盖现有后端名称。

  • 使用 get_backend() 方法获取已配置的后端名称。

示例

import matplotlib
backend = matplotlib.get_backend()
print("The current backend name is: ", backend)
matplotlib.rcParams['backend'] = 'TkAgg'
backend = matplotlib.get_backend()
print("Configured backend name is: ", backend)

输出

The current backend name is: GTK3Agg
Configured backend name is: TkAgg

更新于: 08-05-2021

283 次浏览

开启您的职业生涯

通过完成课程获得证书

开始
广告
© . All rights reserved.