Python 绘制空数据帧

Python 绘制空数据帧,python,python-3.x,pandas,Python,Python 3.x,Pandas,我可以强制空数据框进行绘图吗?我正在填写xlim和yticks,我不明白为什么不可能 >>> df Empty DataFrame Columns: [time, ch, 0] Index: [] >>> df.plot(x="time", y="ch", ax=ax, ... xlim=(start, end), yticks=range(ymin, ymax+

我可以强制空数据框进行绘图吗?我正在填写
xlim
yticks
,我不明白为什么不可能

>>> df
Empty DataFrame
Columns: [time, ch, 0]
Index: []

>>> df.plot(x="time", y="ch",
            ax=ax,
            ...
            xlim=(start, end),
            yticks=range(ymin, ymax+1))
...
TypeError: Empty 'DataFrame': no numeric data to plot
还尝试使用
matplotlib.pyplot
进行绘图,但如果我通过
ax
,它将以
KeyError
结束

>>> plt.plot()
>>> plt.axes(ax)
...
KeyError: <matplotlib.axes._subplots.AxesSubplot object at 0x00000000060E6BE0>
plt.plot() >>>plt.轴(ax) ... 关键错误:
绘制此空df的目的是什么?因此,无论输入数据如何,我的GUI看起来都是一样的。那么,您可以测试空性并相应地调用
plot()
?(
df.plot()
plt.plot()
)也尝试过了,但是如果我通过
ax
,它会以
KeyError
结束。如果你想在已经存在的图形中用子图绘制空图,你可以在df为空时通过,或者以其他方式绘制。或者,如果您只想设置轴,只需执行
ax.set\u xlim()
ax.set\u ylim()
。但我想你的问题还不清楚。到目前为止,您的GUI中有哪些内容,您期望得到什么?