假设我有以下设置:
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(5)
y = np.exp(x)
fig1 = plt.figure()
ax1 = fig1.add_subplot(111)
ax1.plot(x, y)
我想在主图(或子图)上添加一个标题。
我尝试过:
> fig1.title('foo')
AttributeError: 'Figure' object has no attribute 'title'
和
> ax1.title('foo')
TypeError: 'Text' object is not callable
我该如何使用面向对象编程接口来设置 matplotlib 中的这些属性?
更一般地说,我在哪里可以找到 matplotlib 类的层次结构及其相应的方法?
figure
确实有suptitle
方法,可以让您在多个子图上放置一个标题。 - physicsmichael