Skip to content

NaN causes plt.vlines to not scale y limits #7406

Closed
@dadkins

Description

@dadkins

I have reduced the error to the following code snippet which I run in a Jupyter notebook. A NaN as the first item in the series causes plt.vlines to not scale the y limits appropriately. The data values are in the thousands, but the ylimits are [-0.06, 0.06].

%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import sys

print sys.version
print 'pandas', pd.__version__
print 'matplotlib', matplotlib.__version__
df = pd.DataFrame(index = pd.DatetimeIndex(['2016-10-07', '2016-10-14', '2016-10-21', '2016-10-28'], name='Date'),
                  data = [np.nan, -1000, -3000, 4500],
                  columns = ['Amount'])
print df

plt.figure(figsize=(12,3))
plt.vlines(df.index, 0, df['Amount'])
2.7.12 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:42:40) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
pandas 0.19.0
matplotlib 1.5.3
            Amount
Date              
2016-10-07     NaN
2016-10-14 -1000.0
2016-10-21 -3000.0
2016-10-28  4500.0
  • Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)
    1.5.3, python 2.7.12, Linux

  • How did you install Matplotlib and Python (pip, anaconda, from source ...)
    conda

  • [ ]
    matplotlib-bug

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions