From ef7f82a36b008652a1b6c9dd3a14ddefe9104af4 Mon Sep 17 00:00:00 2001 From: isha Date: Sun, 7 Dec 2025 04:13:34 +0000 Subject: [PATCH] Fix: Lightcurve.plot now correctly handles error bars by bypassing parent check --- stingray/lightcurve.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/stingray/lightcurve.py b/stingray/lightcurve.py index c6cff03b6..eb54109bb 100644 --- a/stingray/lightcurve.py +++ b/stingray/lightcurve.py @@ -1635,9 +1635,10 @@ def plot( if not self.input_counts: flux_attr = "countrate" - return super().plot( + # 1. Let the parent plot the main points (We force witherrors=False so it doesn't try and fail) + ax = super().plot( flux_attr, - witherrors=witherrors, + witherrors=False, labels=labels, ax=ax, title=title, @@ -1648,6 +1649,22 @@ def plot( axis_limits=axis_limits, ) + # 2. Manually plot the error bars ourselves + if witherrors: + err_col = flux_attr + "_err" + # Only try to plot if the error data actually exists + if hasattr(self, err_col): + ax.errorbar( + self.time, + getattr(self, flux_attr), + yerr=getattr(self, err_col), + fmt="none", # "none" means don't draw the dots again (parent already did) + ecolor="k", # Black error bars (optional, but looks standard) + zorder=10 + ) + + return ax + @classmethod def read( cls, filename, fmt=None, format_=None, err_dist="gauss", skip_checks=False, **fits_kwargs