|
1 | | -""" pyplots.ai |
| 1 | +"""pyplots.ai |
2 | 2 | line-retention-cohort: User Retention Curve by Cohort |
3 | 3 | Library: highcharts unknown | Python 3.14.3 |
4 | 4 | Quality: 82/100 | Created: 2026-03-16 |
|
78 | 78 | "labels": {"style": {"fontSize": "28px"}, "format": "{value}%"}, |
79 | 79 | "min": 0, |
80 | 80 | "max": 100, |
| 81 | + "tickInterval": 20, |
81 | 82 | "gridLineWidth": 1, |
82 | | - "gridLineColor": "rgba(0, 0, 0, 0.12)", |
| 83 | + "gridLineColor": "rgba(0, 0, 0, 0.08)", |
83 | 84 | "plotLines": [ |
84 | 85 | { |
85 | 86 | "value": 20, |
|
109 | 110 | "x": -30, |
110 | 111 | } |
111 | 112 |
|
| 113 | +# Tooltip - distinctive Highcharts feature |
| 114 | +chart.options.tooltip = { |
| 115 | + "shared": True, |
| 116 | + "valueSuffix": "%", |
| 117 | + "headerFormat": '<span style="font-size:24px;font-weight:bold">{point.key}</span><br/>', |
| 118 | + "pointFormat": '<span style="color:{series.color}">\u25cf</span> {series.name}: <b>{point.y}%</b><br/>', |
| 119 | + "style": {"fontSize": "20px"}, |
| 120 | +} |
| 121 | + |
112 | 122 | # Plot options |
113 | 123 | chart.options.plot_options = { |
114 | | - "line": {"lineWidth": 5, "marker": {"enabled": True, "radius": 9, "lineWidth": 2, "lineColor": "#ffffff"}} |
| 124 | + "line": { |
| 125 | + "lineWidth": 5, |
| 126 | + "marker": {"enabled": True, "radius": 9, "lineWidth": 2, "lineColor": "#ffffff"}, |
| 127 | + "animation": False, |
| 128 | + } |
115 | 129 | } |
116 | 130 |
|
117 | | -# Colors - cohesive palette starting with Python Blue, older cohorts lighter |
118 | | -colors = ["#a3c4d9", "#7baac4", "#5290ae", "#306998", "#1a4d6e"] |
| 131 | +# Colors - distinct, colorblind-safe palette starting with Python Blue |
| 132 | +colors = ["#306998", "#e07b39", "#2ca02c", "#d62728", "#8c564b"] |
119 | 133 |
|
120 | 134 | # Add series - older cohorts first (thinner), newest last (thickest) |
121 | 135 | for i, (cohort, rates) in enumerate(retention_data.items()): |
|
125 | 139 | series.color = colors[i] |
126 | 140 | series.line_width = 3 + i |
127 | 141 | series.marker = {"radius": 5 + i} |
| 142 | + # Zones: dash line below 20% retention target (distinctive Highcharts feature) |
| 143 | + series.zone_axis = "y" |
| 144 | + series.zones = [{"value": 20, "dashStyle": "Dot"}, {"dashStyle": "Solid"}] |
128 | 145 | chart.add_series(series) |
129 | 146 |
|
130 | 147 | # Export |
|
0 commit comments