KM with CI ribbon does not show correctly with plotnine
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- data-visualization
Research direction
Reproduce the example using the merged survival and confidence-interval data, then inspect the behavior of p9.geom_step and p9.geom_ribbon together. Compare the rendered ribbon with the lifelines plot and determine whether the issue is in the supplied data alignment or plotnine rendering; done means the confidence interval follows the survival curve correctly.
Written by the indexing model from the issue text.
Description
Using default code
from lifelines.datasets import load_dd
data = load_dd()
kmf = KaplanMeierFitter()
kmf.fit(data["duration"], event_observed=data["observed"])
kmf.plot_survival_function()
plt.xlim(0, 20)
plt.show()
produces KM curve with CI ribbon as expected, attached.
However, combined with the following this plotnine code
km_df = kmf.survival_function_.reset_index()
km_df.columns = ["Time", "Survival"]
ci_df = kmf.confidence_interval_.reset_index()
ci_df.columns = ["Time", "Lower", "Upper"]
km_merged = km_df.merge(ci_df, on="Time")
(
p9.ggplot(km_merged, p9.aes(x="Time", y="Survival")) +
p9.geom_step(size=1.2, color="blue") +
p9.geom_ribbon(p9.aes(ymin="Lower", ymax="Upper"), alpha=0.25, fill="blue")
)
the CI ribbon is not computed/aligned correctly with the survival function, see attached.
Any idea what is going wrong?
- Dominant language
- Python
- Stars
- 4.8k
- Forks
- 269
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from has2k1/plotnine
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Feature request: add rotation_mode param to geom_textPossibly taken A pull request linked to this issue is open or already merged. OpenFeature
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
position_dodge2() leaves nested rectangles overlappingPossibly taken @MahnoorAhmed999 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
-
Enhancement
Difficulty 3/5 Half a day Newbie friendliness 55/100
-
Enhancement
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
plone/plone.observability#114 ·
Maintainers usually reply within 1 day
-
area:docs type:docs
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
jejjohnson/gauss_flows#246 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
openvax/varcode#824 · 1 comment ·
Maintainers usually reply within 1 day
-
netbox status: needs triage type: feature
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
netbox-community/netbox#23868 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
emeryberger/CSrankings#15757 ·
Maintainers usually reply within 9 days