matplot lib获取子图的窗口大小

时间:2015-06-30 14:11:10

标签: python python-2.7 matplotlib tkinter

如果我有一个AxesSubplot对象,我怎样才能获得该图的窗口大小?我可以使用get_xlim(),但这会返回一个参考轴标签的值。我希望以窗口的形式获得用于Tkinter目的的绘图大小。

fig = getFig() 
w = fig.?
h = fig.?

# will be used in conjunction with Tkinter window values
sw = window.winfo_screenwidth()
sh = window.winfo_screenheight()

1 个答案:

答案 0 :(得分:1)

我认为你可能想要的是使用Figure类来处理这个问题。您需要创建一个图形,然后从中获取AxesSubplot。类似的东西:

from matplotlib import pyplot

fig = pyplot.figure()
axes = fig.add_subplot(1,1,1)
w = fig.get_figwidth()
h = fig.get_figwidth()

get_figwidthget_figheight