Question: I have a pandas data frame with zero values and my plot looks like following:

[![enter image description here](https://i.stack.imgur.com/fFsLf.png)](https://i.stack.imgur.com/fFsLf.png)

I want to mask zero values in the plot. Following is what I am using to plot:

```
ro_list = pd.DataFrame({'Annual min' : annual_ro_min, 'Annual max': annual_ro_max})
ro_list.plot.line(grid=True, ax=ax1, ylim=(0,200), figsize=(5,5))
plt.show()

```

Any suggestions would be appreciative.

Answer: 
the plotting engine accepts `np.nan` values that are left out. `0`s are plotted normally.

```
import pandas as pd
import numpy as np

df = pd.DataFrame([{
    'A' : .5,
    'B' : .5
},{
    'A' : 1,
    'B' : 2
},{
    'A' : 2,
    'B' : 0
},{
    'A' : 1,
    'B' : 2
},{
    'A' : 0,
    'B' : 1
}])

df.replace(0, np.nan).plot()

```

[![replacement](https://i.stack.imgur.com/40hAe.png)](https://i.stack.imgur.com/40hAe.png)

If you want to connect the lines around missing data, you could use

```
df[np.logical_and(df.A != 0, df.B != 0)].plot()

```

[![enter image description here](https://i.stack.imgur.com/n0x4m.png)](https://i.stack.imgur.com/n0x4m.png)

or

```
df[df.A != 0].plot()
df[df.B != 0].plot()

```

[![enter image description here](https://i.stack.imgur.com/cKxGa.png)](https://i.stack.imgur.com/cKxGa.png)

note, that in the last plot, the light blue line connects between `1` and `3`
you can use pipeline

```
(ro_list.query(' "Annual min"!=0 and "Annual max"!=0 ')
        .plot.line()
)

```