plotnine gives an error when trying to draw geom_line with non-constant path parameters, but for which lines with less than 2 data points were dropped.
I believe this is because the code below resets the index before removing single point lines
| data.reset_index(drop=True, inplace=True) | |
| # drop lines with less than two points | |
| c = Counter(data['group']) | |
| counts = np.array([c[v] for v in data['group']]) | |
| data = data[counts >= 2] |
This then results in iloc indexing out of bounds
| for _, df in data.groupby('group'): | |
| idx = df.index | |
| indices.extend(idx[:-1]) # One line from two points | |
| x = data['x'].iloc[idx] |
Example:
from plotnine import *
import pandas as pd
df = pd.DataFrame({"A" : [1,1,1,1,1],
"B" : [0,0,1,2,2],
"C" : [1,1,1,1,1],
"D" : [1,2,3,4,5]})
ggplot(df) + geom_line(aes(x="A", y="C", group="B", color="D"))
Error:
IndexError: index 4 is out of bounds for size 4
This is with version 0.6.0