Matplotlib fields when plotting with Pandas

I'm trying to set the margins so that all my points are visible when plotting with matplotlib, but it doesn't seem to have added them correctly. Below is my code and output.

I am using IPython with magic matplotlib magic command.

Is there something I am doing obviously wrong?

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)

      

Matplotlib Output

+3


source to share


1 answer


see the following documentation for set_ylim and set_xlim http://matplotlib.org/api/axes_api.html?highlight=set_xlim

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)

      



enter image description here

+4


source







All Articles