且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

X 轴散点图 Pandas MatplotLib 上的限制范围

更新时间:2023-11-22 08:38:46

您可以创建轴,然后使用 ax.xlim().

You can create axes and then use ax.xlim().

import pandas as pd
df = pd.DataFrame({'x':[1,2,3], 'y':[3,4,5]})
fig = plt.figure()
ax = plt.subplot(111)
df.plot(x='x',y='y',ax=ax, kind='scatter')
ax.set_xlim(2,3)