Skip to content

Commit d9438a8

Browse files
committed
fixed nbs
1 parent 1cbe764 commit d9438a8

File tree

12 files changed

+2465
-2235
lines changed

12 files changed

+2465
-2235
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Install dependencies
2626
run: |
2727
python -m pip install --upgrade pip
28-
pip install -e ".[dev]"
28+
pip install -e ".[dev,docs]"
2929
3030
- name: Run tests
3131
run: |

docs/gallery/facets.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"id": "cell-12",
113113
"metadata": {},
114114
"outputs": [],
115-
"source": "(ggplot(df, aes(x='x', y='y'))\n + geom_point(alpha=0.5)\n + facet_grid(rows='row_var'))"
115+
"source": "(ggplot(df, aes(x='x', y='y'))\n + geom_point(alpha=0.5)\n + facet_grid(rows='row_var', cols='.'))"
116116
},
117117
{
118118
"cell_type": "markdown",
@@ -128,7 +128,7 @@
128128
"id": "cell-14",
129129
"metadata": {},
130130
"outputs": [],
131-
"source": "(ggplot(df, aes(x='x', y='y'))\n + geom_point(alpha=0.5)\n + facet_grid(cols='col_var'))"
131+
"source": "(ggplot(df, aes(x='x', y='y'))\n + geom_point(alpha=0.5)\n + facet_grid(rows='.', cols='col_var'))"
132132
},
133133
{
134134
"cell_type": "markdown",

docs/gallery/theming.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@
364364
"id": "cell-40",
365365
"metadata": {},
366366
"outputs": [],
367-
"source": "df = pd.DataFrame({\n 'x': np.random.randn(100),\n 'y': np.random.randn(100)\n})\n\n(ggplot(df, aes(x='x', y='y'))\n + geom_point(size=6)\n + geom_smooth(method='lm', color='red')\n + theme_minimal()\n + theme(\n axis_title=element_text(size=12),\n plot_title=element_text(size=14, face='bold')\n )\n + labs(title='Scatter with Linear Fit',\n x='Independent Variable',\n y='Dependent Variable'))"
367+
"source": "df = pd.DataFrame({\n 'x': np.random.randn(100),\n 'y': np.random.randn(100)\n})\n\n(ggplot(df, aes(x='x', y='y'))\n + geom_point(size=6)\n + geom_smooth(method='lm', color='red')\n + theme_minimal()\n + theme(\n axis_title=element_text(size=12),\n plot_title=element_text(size=14)\n )\n + labs(title='Scatter with Linear Fit',\n x='Independent Variable',\n y='Dependent Variable'))"
368368
},
369369
{
370370
"cell_type": "markdown",

docs/getting-started.ipynb

Lines changed: 94 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
{
2-
"nbformat": 4,
3-
"nbformat_minor": 5,
4-
"metadata": {
5-
"kernelspec": {
6-
"display_name": "Python 3",
7-
"language": "python",
8-
"name": "python3"
9-
},
10-
"language_info": {
11-
"name": "python",
12-
"version": "3.12.0"
13-
}
14-
},
152
"cells": [
163
{
174
"cell_type": "markdown",
@@ -56,7 +43,11 @@
5643
"execution_count": null,
5744
"metadata": {},
5845
"outputs": [],
59-
"source": "from ggplotly import *\nimport pandas as pd"
46+
"source": [
47+
"from ggplotly import *\n",
48+
"import pandas as pd\n",
49+
"import numpy as np"
50+
]
6051
},
6152
{
6253
"cell_type": "markdown",
@@ -70,7 +61,16 @@
7061
"execution_count": null,
7162
"metadata": {},
7263
"outputs": [],
73-
"source": "# Create some data\ndf = pd.DataFrame({\n 'x': [1, 2, 3, 4, 5],\n 'y': [2, 4, 3, 5, 4]\n})\n\n# Create a scatter plot\n(ggplot(df, aes(x='x', y='y')) + geom_point())"
64+
"source": [
65+
"# Create some data\n",
66+
"df = pd.DataFrame({\n",
67+
" 'x': [1, 2, 3, 4, 5],\n",
68+
" 'y': [2, 4, 3, 5, 4]\n",
69+
"})\n",
70+
"\n",
71+
"# Create a scatter plot\n",
72+
"ggplot(df, aes(x='x', y='y')) + geom_point()"
73+
]
7474
},
7575
{
7676
"cell_type": "markdown",
@@ -91,7 +91,24 @@
9191
"execution_count": null,
9292
"metadata": {},
9393
"outputs": [],
94-
"source": "(\n ggplot(df, aes(x='x', y='y', color='category')) # Data + aesthetics\n + geom_point(size=3) # Geom\n + scale_color_brewer(palette='Set1') # Scale\n + theme_minimal() # Theme\n + labs(title='My Plot', x='X Axis', y='Y Axis') # Labels\n)"
94+
"source": [
95+
"# More complete sample data\n",
96+
"np.random.seed(42)\n",
97+
"df = pd.DataFrame({\n",
98+
" 'x': np.random.randn(50),\n",
99+
" 'y': np.random.randn(50),\n",
100+
" 'category': np.random.choice(['A', 'B', 'C'], 50),\n",
101+
" 'values': np.random.rand(50) * 10\n",
102+
"})\n",
103+
"\n",
104+
"(\n",
105+
" ggplot(df, aes(x='x', y='y', color='category')) # Data + aesthetics\n",
106+
" + geom_point(size=5) # Geom\n",
107+
" + scale_color_brewer(palette='Set1') # Scale\n",
108+
" + theme_minimal() # Theme\n",
109+
" + labs(title='My Plot', x='X Axis', y='Y Axis') # Labels\n",
110+
")"
111+
]
95112
},
96113
{
97114
"cell_type": "markdown",
@@ -107,7 +124,9 @@
107124
"execution_count": null,
108125
"metadata": {},
109126
"outputs": [],
110-
"source": "ggplot(df, aes(x='x', y='y', color='category')) + geom_point()"
127+
"source": [
128+
"ggplot(df, aes(x='x', y='y', color='category')) + geom_point()"
129+
]
111130
},
112131
{
113132
"cell_type": "markdown",
@@ -121,7 +140,9 @@
121140
"execution_count": null,
122141
"metadata": {},
123142
"outputs": [],
124-
"source": "ggplot(df, aes(x='x', y='y')) + geom_point() + geom_line()"
143+
"source": [
144+
"ggplot(df, aes(x='x', y='y')) + geom_point() + geom_smooth()"
145+
]
125146
},
126147
{
127148
"cell_type": "markdown",
@@ -135,7 +156,9 @@
135156
"execution_count": null,
136157
"metadata": {},
137158
"outputs": [],
138-
"source": "ggplot(df, aes(x='x', y='y')) + geom_point() + facet_wrap('category')"
159+
"source": [
160+
"ggplot(df, aes(x='x', y='y')) + geom_point() + facet_wrap('category')"
161+
]
139162
},
140163
{
141164
"cell_type": "markdown",
@@ -149,48 +172,88 @@
149172
"execution_count": null,
150173
"metadata": {},
151174
"outputs": [],
152-
"source": "# Automatically use DataFrame index\nggplot(df, aes(y='values')) + geom_line()\n\n# Or explicitly\nggplot(df, aes(x='index', y='values')) + geom_line()\n\n# Works with Series too\nseries = pd.Series([1, 2, 3], index=['a', 'b', 'c'])\nggplot(series) + geom_point()"
175+
"source": [
176+
"# Create time series data with index\n",
177+
"ts_df = pd.DataFrame({\n",
178+
" 'values': np.cumsum(np.random.randn(50)) + 50\n",
179+
"}, index=pd.date_range('2024-01-01', periods=50, freq='D'))\n",
180+
"\n",
181+
"# Automatically use DataFrame index\n",
182+
"ggplot(ts_df, aes(y='values')) + geom_line()"
183+
]
153184
},
154185
{
155186
"cell_type": "markdown",
156187
"metadata": {},
157188
"source": [
158-
"## Saving Plots"
189+
"## Built-in Datasets\n",
190+
"\n",
191+
"ggplotly includes classic datasets for learning:"
159192
]
160193
},
161194
{
162195
"cell_type": "code",
163196
"execution_count": null,
164197
"metadata": {},
165198
"outputs": [],
166-
"source": "# Create plot\np = ggplot(df, aes(x='x', y='y')) + geom_point()\n\n# Save as HTML (interactive)\np.write_html('plot.html')\n\n# Save as image (requires kaleido)\np.write_image('plot.png')\n\n# Or use ggsave\nggsave(p, 'plot.png', width=800, height=600)"
167-
},
168-
{
169-
"cell_type": "markdown",
170-
"metadata": {},
171199
"source": [
172-
"## Built-in Datasets\n",
200+
"from ggplotly import data\n",
173201
"\n",
174-
"ggplotly includes classic datasets for learning:"
202+
"# See all available datasets\n",
203+
"data()"
175204
]
176205
},
177206
{
178207
"cell_type": "code",
179208
"execution_count": null,
180209
"metadata": {},
181210
"outputs": [],
182-
"source": "from ggplotly import data\n\n# Load a dataset\nmpg = data('mpg')\ndiamonds = data('diamonds')\niris = data('iris')\n\n# See all available datasets\ndata()"
211+
"source": [
212+
"# Load the iris dataset\n",
213+
"iris = data('iris')\n",
214+
"\n",
215+
"ggplot(iris, aes(x='sepal_length', y='sepal_width', color='species')) + geom_point()"
216+
]
183217
},
184218
{
185219
"cell_type": "markdown",
186220
"metadata": {},
187221
"source": [
222+
"## Saving Plots\n",
223+
"\n",
224+
"```python\n",
225+
"# Create plot\n",
226+
"p = ggplot(df, aes(x='x', y='y')) + geom_point()\n",
227+
"\n",
228+
"# Save as HTML (interactive)\n",
229+
"p.write_html('plot.html')\n",
230+
"\n",
231+
"# Save as image (requires kaleido)\n",
232+
"p.write_image('plot.png')\n",
233+
"\n",
234+
"# Or use ggsave\n",
235+
"ggsave(p, 'plot.png', width=800, height=600)\n",
236+
"```\n",
237+
"\n",
188238
"## Next Steps\n",
189239
"\n",
190240
"- [Aesthetics Guide](guide/aesthetics.ipynb) - Learn about mapping data to visual properties\n",
191241
"- [Geoms Reference](guide/geoms.ipynb) - Explore all available geometric objects\n",
192242
"- [Themes](guide/themes.ipynb) - Customize the look of your plots"
193243
]
194244
}
195-
]
196-
}
245+
],
246+
"metadata": {
247+
"kernelspec": {
248+
"display_name": "Python 3",
249+
"language": "python",
250+
"name": "python3"
251+
},
252+
"language_info": {
253+
"name": "python",
254+
"version": "3.9.0"
255+
}
256+
},
257+
"nbformat": 4,
258+
"nbformat_minor": 4
259+
}

0 commit comments

Comments
 (0)