question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tsplot crashes when there is only one datapoint

See original GitHub issue

when data has only one datapoint (for a given unit and condition), tsplot crashes with an out of bounds exception.

seaborn/timeseries.py in tsplot(data, time, unit, condition, value, err_style, ci, interpolate, color, estimator, n_boot, err_palette, err_kws, legend, ax, **kwargs)
    328     # Pad the sides of the plot only when not interpolating
    329     ax.set_xlim(x.min(), x.max())
--> 330     x_diff = x[1] - x[0]
    331     if not interpolate:
    332         ax.set_xlim(x.min() - x_diff, x.max() + x_diff)

IndexError: index 1 is out of bounds for axis 0 with size 1

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mwaskomcommented, Jul 7, 2017

Closing with tsplot deprecation.

0reactions
BlackHCcommented, Dec 14, 2016

https://cloud.sagemath.com/projects/26d7dccf-e180-450e-b348-05e3242d8779/files/2016-12-14-171122.ipynb

import pandas as pd
import seaborn

# This crashes.
data = [
    {'unit': 1, 'condition': '2015-12-02', 'tick': 1, 'value': 2},  
    {'unit': 1, 'condition': '2015-12-02', 'tick': 2, 'value': 3},
    {'unit': 1, 'condition': '2015-12-01', 'tick': 1, 'value': 1}, 
]
data_frame = pd.DataFrame(data)
seaborn.tsplot(data_frame, time="tick", unit="unit", condition="condition", value="value", err_style="unit_traces")

Creating the example, I noticed that it only breaks if the single data point trace comes last because x is a loop variable, so the padding only takes the last trace into account… which means that the padding is probably off when you have traces that vary wildly in their span in general.

Thanks, Andreas

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toad Data Point - Commonly Crashes, Performance Issues
A common issue we find is that the program will randomly crash/close out completely. This occurs both while it is in active use...
Read more >
What's new in each version — seaborn 0.11.2 documentation
The tsplot() function was rewritten to accept data in a long-form DataFrame and to plot different traces by condition. This introduced a relatively...
Read more >
Matplotlib crashes after saving many plots - Stack Overflow
I would create a single figure and clear the figure each time (use .clf ). import matplotlib.pyplot as plt fig = plt.figure() for...
Read more >
Excel graphing having a one data point drop out, data errantly ...
I have tried over writing the formulas as the graphs generally don't graph the raw data but formulas from it to analyze data,...
Read more >
Time Series Data Visualization with Python
Line plots of observations over time are popular, but there is a suite of other plots that you can use to learn more...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found