Python 使用熊猫打印时的Matplotlib边距

Python 使用熊猫打印时的Matplotlib边距,python,pandas,matplotlib,Python,Pandas,Matplotlib,我正在尝试设置边距,以便在使用matplotlib打印时所有点都可见,但它似乎无法正确添加它们。下面是我的代码和输出 我正在将IPython与%matplotlib magic命令一起使用 有什么事情是我明显做错了吗 import matplotlib.pyplot as plt import pandas as pd d = pd.DataFrame(pd.Series(range(10))*2) a = d.plot(style = "o-") a.set_axis_bgcolor('g

我正在尝试设置边距,以便在使用matplotlib打印时所有点都可见,但它似乎无法正确添加它们。下面是我的代码和输出

我正在将IPython与%matplotlib magic命令一起使用

有什么事情是我明显做错了吗

import matplotlib.pyplot as plt
import pandas as pd


d = pd.DataFrame(pd.Series(range(10))*2)
a = d.plot(style = "o-")
a.set_axis_bgcolor('g') 
a.margins(.05)

有关set_ylim和set_xlim,请参阅以下文档


在不设置x和y LIM的情况下,如何执行此操作?例如,我想用分类变量来做这个:a.autoscale(tight=False)Kevin,这就是我缺少的。谢谢大家!@Kevin你评论中的解决方案实际上比你在回答中给出的要好。为了完整性,可能值得在这里添加…a.自动缩放(紧密=假)
d = pd.DataFrame(pd.Series(range(10))*2)
a = d.plot(style = "o-")
a.set_axis_bgcolor('g')
a.set_ylim([-1,19])
a.set_xlim([-1,11])
a.margins(.05)