matplotlib.pyplot.subplots() - 如何设置图形的名称? [英] matplotlib.pyplot.subplots() - how to set the name of the figure?
本文介绍了matplotlib.pyplot.subplots() - 如何设置图形的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用PyPlot的fig()函数创建单个图时,可以使用字符串作为参数设置出现窗口的名称:
When I create a single plot using the figure()-function of PyPlot, I can set the name of the appearing window using a string as argument:
import matplotlib.pyplot as plt
figure = plt.figure('MyName')
函数 plt.subplots() 不接受字符串作为第一个参数.例如:
The function plt.subplots() doesn´t accept strings as first argument. For example:
plt.subplots(2,2) # for creating a window with 4 subplots
那么我该如何设置图形的名称?
So how can I set the name of the figure?
推荐答案
摘自 文档:
import matplotlib.pyplot as plt
#...
# Just a figure and one subplot
f, ax = plt.subplots()
ax.plot(x, y)
ax.set_title('Simple plot')
并且,要更改窗口的标题:
And, to change the title of the Window:
import matplotlib.pyplot as plt
fig = plt.figure()
fig.canvas.set_window_title('My Window Title')
plt.show()
这篇关于matplotlib.pyplot.subplots() - 如何设置图形的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文