Skip to content

Commit 6493c76

Browse files
committed
tsa2
1 parent 2da4d32 commit 6493c76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1329
-215
lines changed

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ ggplot(df, aes(x='x', y='y')) + geom_point() + facet_wrap('group')
3232

3333
## ggplot2 Function Coverage
3434

35-
### Geoms (34)
35+
### Geoms (44)
3636

3737
| Function | Description |
3838
|----------|-------------|
3939
| `geom_point` | Scatter plots |
4040
| `geom_line` | Line plots (sorted by x) |
41+
| `geom_lines` | Multi-series line plots |
4142
| `geom_path` | Path plots (unsorted) |
4243
| `geom_bar` | Bar charts |
4344
| `geom_col` | Column charts (pre-computed heights) |
@@ -61,18 +62,26 @@ ggplot(df, aes(x='x', y='y')) + geom_point() + facet_wrap('group')
6162
| `geom_contour` | Contour lines |
6263
| `geom_contour_filled` | Filled contours |
6364
| `geom_map` | Choropleth maps |
64-
| `geom_point_map` | Points on maps |
65+
| `geom_sf` | Simple features (geographic) |
6566
| `geom_range` | Range plots (min/max/avg) |
6667
| `geom_edgebundle` | Edge bundling for networks |
67-
| `geom_sf` | Simple features (geographic) |
6868
| `geom_searoute` | Maritime shipping routes |
6969
| `geom_point_3d` | 3D scatter plots |
7070
| `geom_surface` | 3D surface plots |
7171
| `geom_wireframe` | 3D wireframe plots |
7272
| `geom_candlestick` | Candlestick charts (financial) |
7373
| `geom_ohlc` | OHLC charts (financial) |
74-
75-
### Stats (7)
74+
| `geom_waterfall` | Waterfall charts (financial) |
75+
| `geom_sankey` | Sankey flow diagrams |
76+
| `geom_fanchart` | Fan charts for uncertainty |
77+
| `geom_stl` | STL decomposition plots |
78+
| `geom_acf` | Autocorrelation function plots |
79+
| `geom_pacf` | Partial autocorrelation plots |
80+
| `geom_norm` | Normal distribution overlay |
81+
| `geom_qq` | Q-Q plots (theoretical vs sample quantiles) |
82+
| `geom_qq_line` | Q-Q reference line through Q1/Q3 |
83+
84+
### Stats (13)
7685

7786
| Function | Description |
7887
|----------|-------------|
@@ -83,6 +92,12 @@ ggplot(df, aes(x='x', y='y')) + geom_point() + facet_wrap('group')
8392
| `stat_ecdf` | Empirical CDF |
8493
| `stat_smooth` | Smoothing with CI |
8594
| `stat_summary` | Summary statistics |
95+
| `stat_contour` | Contour computation |
96+
| `stat_fanchart` | Fan chart percentiles |
97+
| `stat_function` | Apply function to data range |
98+
| `stat_stl` | STL time series decomposition |
99+
| `stat_qq` | Compute Q-Q quantiles |
100+
| `stat_qq_line` | Compute Q-Q reference line |
86101

87102
### Scales (17)
88103

@@ -166,4 +181,4 @@ ggplot(df, aes(x='x', y='y')) + geom_point() + facet_wrap('group')
166181
| `ggsave` | Save plots to file |
167182
| `ggsize` | Set plot dimensions |
168183

169-
## Total: ~97 ggplot2-equivalent functions
184+
## Total: ~113 ggplot2-equivalent functions

docs/api/geoms.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ Geometric objects (geoms) are the visual elements used to represent data in a pl
176176
options:
177177
show_root_heading: true
178178

179+
::: ggplotly.geoms.geom_waterfall.geom_waterfall
180+
options:
181+
show_root_heading: true
182+
179183
## Time Series Geoms
180184

181185
::: ggplotly.geoms.geom_stl.geom_stl
@@ -199,3 +203,9 @@ Geometric objects (geoms) are the visual elements used to represent data in a pl
199203
::: ggplotly.geoms.geom_searoute.geom_searoute
200204
options:
201205
show_root_heading: true
206+
207+
## Flow Geoms
208+
209+
::: ggplotly.geoms.geom_sankey.geom_sankey
210+
options:
211+
show_root_heading: true

docs/gallery/networks.ipynb

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,54 @@
333333
"- Edge weights (if provided)\n",
334334
"- All algorithm parameters (K, E, C, P, S, etc.)"
335335
]
336+
},
337+
{
338+
"cell_type": "markdown",
339+
"id": "6nj4t32vklf",
340+
"source": "## Sankey Diagrams\n\nSankey diagrams visualize flows between nodes, where the width of each link is proportional to the flow quantity.\n\n### Basic Sankey",
341+
"metadata": {}
342+
},
343+
{
344+
"cell_type": "code",
345+
"id": "zvld5kwh3o",
346+
"source": "# Simple flow from sources to targets\nflow_df = pd.DataFrame({\n 'source': ['A', 'A', 'B', 'B', 'C'],\n 'target': ['X', 'Y', 'X', 'Y', 'Y'],\n 'value': [10, 20, 15, 25, 5]\n})\n\n(ggplot(flow_df, aes(source='source', target='target', value='value'))\n + geom_sankey()\n + labs(title='Basic Sankey Diagram'))",
347+
"metadata": {},
348+
"execution_count": null,
349+
"outputs": []
350+
},
351+
{
352+
"cell_type": "markdown",
353+
"id": "hcarax6s7vu",
354+
"source": "### Multi-Stage Sankey\n\nFor multi-stage flows (e.g., budget allocation):",
355+
"metadata": {}
356+
},
357+
{
358+
"cell_type": "code",
359+
"id": "nfornzgzfb",
360+
"source": "# Multi-stage budget flow\nbudget_df = pd.DataFrame({\n 'source': ['Budget', 'Budget', 'Sales', 'Sales', 'Marketing', 'Marketing', 'R&D'],\n 'target': ['Sales', 'Marketing', 'Revenue', 'Costs', 'Revenue', 'Costs', 'Revenue'],\n 'value': [100, 80, 90, 10, 60, 20, 50]\n})\n\n(ggplot(budget_df, aes(source='source', target='target', value='value'))\n + geom_sankey(node_pad=20, node_thickness=25)\n + labs(title='Budget Allocation Flow'))",
361+
"metadata": {},
362+
"execution_count": null,
363+
"outputs": []
364+
},
365+
{
366+
"cell_type": "markdown",
367+
"id": "oi2t776yfqq",
368+
"source": "### Custom Colors",
369+
"metadata": {}
370+
},
371+
{
372+
"cell_type": "code",
373+
"id": "0nrov454s3bk",
374+
"source": "# Custom node colors\n(ggplot(flow_df, aes(source='source', target='target', value='value'))\n + geom_sankey(\n node_color=['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd'],\n link_alpha=0.5\n )\n + labs(title='Sankey with Custom Colors'))",
375+
"metadata": {},
376+
"execution_count": null,
377+
"outputs": []
378+
},
379+
{
380+
"cell_type": "markdown",
381+
"id": "sg25xx2i7v",
382+
"source": "### Sankey Parameters\n\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| `node_pad` | 15 | Padding between nodes |\n| `node_thickness` | 20 | Thickness of nodes |\n| `node_color` | auto | Color(s) for nodes |\n| `link_color` | auto | Color for links (uses source node color) |\n| `link_alpha` | 0.4 | Transparency of links |\n| `orientation` | 'h' | 'h' (horizontal) or 'v' (vertical) |\n| `arrangement` | 'snap' | Node arrangement: 'snap', 'perpendicular', 'freeform', 'fixed' |",
383+
"metadata": {}
336384
}
337385
],
338386
"metadata": {
@@ -348,4 +396,4 @@
348396
},
349397
"nbformat": 4,
350398
"nbformat_minor": 5
351-
}
399+
}

docs/gallery/statistical.ipynb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21516,6 +21516,54 @@
2151621516
" + labs(title='Residuals vs Fitted', x='Fitted Values', y='Residuals'))"
2151721517
]
2151821518
},
21519+
{
21520+
"cell_type": "markdown",
21521+
"id": "5bi0xmpz20y",
21522+
"source": "## Waterfall Charts\n\nWaterfall charts show how an initial value is affected by intermediate positive or negative values.\n\n### Basic Waterfall",
21523+
"metadata": {}
21524+
},
21525+
{
21526+
"cell_type": "code",
21527+
"id": "5s0e0inllcn",
21528+
"source": "# Basic waterfall showing quarterly changes\nwaterfall_df = pd.DataFrame({\n 'category': ['Q1 Sales', 'Q2 Growth', 'Q3 Decline', 'Q4 Recovery', 'Year Total'],\n 'value': [100, 50, -30, 20, 0],\n 'measure': ['absolute', 'relative', 'relative', 'relative', 'total']\n})\n\n(ggplot(waterfall_df, aes(x='category', y='value', measure='measure'))\n + geom_waterfall()\n + labs(title='Quarterly Sales Waterfall'))",
21529+
"metadata": {},
21530+
"execution_count": null,
21531+
"outputs": []
21532+
},
21533+
{
21534+
"cell_type": "markdown",
21535+
"id": "hk7c8dkqt45",
21536+
"source": "### Financial Statement Waterfall\n\nCommon use case for income statement analysis:",
21537+
"metadata": {}
21538+
},
21539+
{
21540+
"cell_type": "code",
21541+
"id": "0rim3tnjs79n",
21542+
"source": "# Income statement waterfall\nincome_df = pd.DataFrame({\n 'item': ['Revenue', 'COGS', 'Gross Profit', 'Operating Expenses', 'Operating Income', 'Taxes', 'Net Income'],\n 'amount': [1000, -400, 0, -300, 0, -75, 0],\n 'type': ['absolute', 'relative', 'total', 'relative', 'total', 'relative', 'total']\n})\n\n(ggplot(income_df, aes(x='item', y='amount', measure='type'))\n + geom_waterfall()\n + labs(title='Income Statement Breakdown', y='Amount ($K)'))",
21543+
"metadata": {},
21544+
"execution_count": null,
21545+
"outputs": []
21546+
},
21547+
{
21548+
"cell_type": "markdown",
21549+
"id": "obo7mbmzdfl",
21550+
"source": "### Custom Colors",
21551+
"metadata": {}
21552+
},
21553+
{
21554+
"cell_type": "code",
21555+
"id": "9286z3430xc",
21556+
"source": "# Custom colors for different bar types\n(ggplot(waterfall_df, aes(x='category', y='value', measure='measure'))\n + geom_waterfall(\n increasing_color='#17becf', # Cyan for increases\n decreasing_color='#ff7f0e', # Orange for decreases\n total_color='#1f77b4' # Blue for totals\n )\n + labs(title='Waterfall with Custom Colors'))",
21557+
"metadata": {},
21558+
"execution_count": null,
21559+
"outputs": []
21560+
},
21561+
{
21562+
"cell_type": "markdown",
21563+
"id": "mpqwz5818w",
21564+
"source": "### Waterfall Parameters\n\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| `increasing_color` | '#2ca02c' | Color for positive changes (green) |\n| `decreasing_color` | '#d62728' | Color for negative changes (red) |\n| `total_color` | '#1f77b4' | Color for totals (blue) |\n| `connector_visible` | True | Show connector lines |\n| `connector_color` | gray | Color of connectors |\n| `text_position` | 'outside' | Position of value labels |\n| `orientation` | 'v' | 'v' (vertical) or 'h' (horizontal) |\n\nThe `measure` aesthetic controls bar types:\n- `'absolute'`: Starting value (resets running total)\n- `'relative'`: Change from previous value (default)\n- `'total'`: Shows cumulative total at this point",
21565+
"metadata": {}
21566+
},
2151921567
{
2152021568
"cell_type": "markdown",
2152121569
"id": "4b17be7b",

ggplotly/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
geom_range,
3636
geom_ribbon,
3737
geom_rug,
38+
geom_sankey,
3839
geom_searoute,
3940
geom_segment,
4041
geom_sf,
@@ -46,6 +47,7 @@
4647
geom_tile,
4748
geom_violin,
4849
geom_vline,
50+
geom_waterfall,
4951
geom_wireframe,
5052
)
5153
from .ggplot import ggplot
@@ -189,6 +191,8 @@
189191
"geom_norm",
190192
"geom_qq",
191193
"geom_qq_line",
194+
"geom_sankey",
195+
"geom_waterfall",
192196
"scale_x_continuous",
193197
"scale_y_continuous",
194198
"scale_color_manual",

ggplotly/geoms/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323
from .geom_norm import geom_norm
2424
from .geom_pacf import geom_pacf
2525
from .geom_path import geom_path
26-
from .geom_qq import geom_qq
27-
from .geom_qq_line import geom_qq_line
2826
from .geom_point import geom_point
2927
from .geom_point_3d import geom_point_3d
28+
from .geom_qq import geom_qq
29+
from .geom_qq_line import geom_qq_line
3030
from .geom_range import geom_range
3131
from .geom_ribbon import geom_ribbon
3232
from .geom_rug import geom_rug
33+
from .geom_sankey import geom_sankey
3334
from .geom_searoute import geom_searoute
3435
from .geom_segment import geom_segment
3536
from .geom_smooth import geom_smooth
@@ -40,6 +41,7 @@
4041
from .geom_tile import geom_tile
4142
from .geom_violin import geom_violin
4243
from .geom_vline import geom_vline
44+
from .geom_waterfall import geom_waterfall
4345

4446
__all__ = [
4547
"Geom",
@@ -85,4 +87,6 @@
8587
"geom_norm",
8688
"geom_qq",
8789
"geom_qq_line",
90+
"geom_sankey",
91+
"geom_waterfall",
8892
]

ggplotly/geoms/geom_acf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def _draw_impl(self, fig, data, row, col):
6060
nlags = self.params.get("nlags", 40)
6161
alpha = self.params.get("alpha", 0.05)
6262
color = self.params.get("color", "steelblue")
63-
ci_color = self.params.get("ci_color", "lightblue")
6463
ci_alpha = self.params.get("ci_alpha", 0.3)
6564
bar_width = self.params.get("bar_width", 0.3)
6665

ggplotly/geoms/geom_fanchart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import plotly.graph_objects as go
44

5-
from .geom_base import Geom
65
from ..stats.stat_fanchart import stat_fanchart
6+
from .geom_base import Geom
77

88

99
class geom_fanchart(Geom):

ggplotly/geoms/geom_pacf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def _draw_impl(self, fig, data, row, col):
6666
alpha = self.params.get("alpha", 0.05)
6767
method = self.params.get("method", "ywm")
6868
color = self.params.get("color", "steelblue")
69-
ci_color = self.params.get("ci_color", "lightblue")
7069
ci_alpha = self.params.get("ci_alpha", 0.3)
7170
bar_width = self.params.get("bar_width", 0.3)
7271

0 commit comments

Comments
 (0)