sách gpt4 ai đã đi

python - matplotlib.pyplot.subplots() - 如何设置图形名称?

In lại Tác giả: Space Dog 更新时间:2023-10-29 18:21:12 48 4
mua khóa gpt4 Nike

当我使用 PyPlot 的 figure() 函数创建单个绘图时,我可以使用字符串作为参数来设置出现窗口的名称:

nhập matplotlib.pyplot dưới dạng plt
figure = plt.figure('MyName')

函数 plt.subplots() 不接受字符串作为第一个参数。例如:

plt.subplots(2,2) # for creating a window with 4 subplots

那么如何设置图形的名称呢?

1 Câu trả lời

Lấy từthe docs :

nhập matplotlib.pyplot dưới dạng plt

#...

# Just a figure and one subplot
f, ax = plt.subplots()
ax.plot(x, y)
ax.set_title('Simple plot')

然后,更改窗口的标题:

nhập matplotlib.pyplot dưới dạng plt 
fig = plt.figure()
fig.canvas.manager.set_window_title('My Window Title')
plt.hiển thị()

如果您使用的 Matplotlib 版本 < 3.4,请使用:fig.canvas.set_window_title('My Windows Title')

Reference to deprecation (KaiserKatze 的荣誉)。

关于python - matplotlib.pyplot.subplots() - 如何设置图形名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25387365/

48 4 0
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com