Skip to content

Commit fc1c6d9

Browse files
small edits to data viz
1 parent c251b72 commit fc1c6d9

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

1-foundations/4-api-and-dataviz/foundations-s4-dataviz.ipynb

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
"source": [
3939
"import pandas as pd\n",
4040
"pd.options.mode.chained_assignment = None\n",
41-
"import matplotlib.pyplot as plt\n",
42-
"import seaborn as sns\n",
4341
"import wbgapi as wb"
4442
]
4543
},
@@ -63,6 +61,7 @@
6361
"- Allows low-level customization of plots\n",
6462
"- \"Wordy\" syntax, can get quite complex easily\n",
6563
"- Very popular in scientific programming\n",
64+
"- Ugly aesthetic defaults\n",
6665
"\n",
6766
"Remember this \"picture\"? it was actually a plot created with `matplotlib`."
6867
]
@@ -162,8 +161,8 @@
162161
"metadata": {},
163162
"outputs": [],
164163
"source": [
165-
"y_data = df[df['Country']=='Mexico']['Population'] / 1000000 # x-axis data: population in millions\n",
166-
"x_data = df[df['Country']=='Mexico']['year'] # y-axis data: years we have data for Mexico"
164+
"y_data = df[df['Country']=='Mexico']['Population'] / 1000000 # y-axis data: population in millions\n",
165+
"x_data = df[df['Country']=='Mexico']['year'] # x-axis data: years we have data for Mexico"
167166
]
168167
},
169168
{
@@ -173,6 +172,15 @@
173172
"## Using `matplotlib`"
174173
]
175174
},
175+
{
176+
"cell_type": "code",
177+
"execution_count": null,
178+
"metadata": {},
179+
"outputs": [],
180+
"source": [
181+
"import matplotlib.pyplot as plt"
182+
]
183+
},
176184
{
177185
"cell_type": "code",
178186
"execution_count": null,
@@ -232,6 +240,15 @@
232240
"## Using `seaborn`"
233241
]
234242
},
243+
{
244+
"cell_type": "code",
245+
"execution_count": null,
246+
"metadata": {},
247+
"outputs": [],
248+
"source": [
249+
"import seaborn as sns"
250+
]
251+
},
235252
{
236253
"cell_type": "code",
237254
"execution_count": null,
@@ -275,10 +292,10 @@
275292
"source": [
276293
"A few details to note:\n",
277294
"\n",
278-
"- For this example we defined the x and y-axis data as Pandas series, but they can also be lists (or containers) with numbers or NumPy series\n",
295+
"- For this example we defined the x and y-axis data as Pandas series, but they can also be lists (or containers) with numbers\n",
279296
"- Seaborn accepts two methods to plot visualizations:\n",
280297
" + You either pass the x and y-axis data in the arguments `x`, `y`\n",
281-
" + Or you define a Pandas dataframe input in the arugment `data` and set `x` and `y` equal to the column names you take the x-axis and y-axis data from\n",
298+
" + Or you define a Pandas dataframe input in the argument `data` and set `x` and `y` equal to the column names you take the x-axis and y-axis data from\n",
282299
"- Compare the syntax of both libraries to get the same result:\n",
283300
"\n",
284301
"```\n",
@@ -306,7 +323,7 @@
306323
"# Line plots\n",
307324
"\n",
308325
"- Line plots have a very similar syntax than bar plots in `matplotlib`, but they use the function `plt.plot()` instead of `plt.barplot()`\n",
309-
"- In `seaborn`, the function is `sns.linelplot()`\n",
326+
"- In `seaborn`, the function is `sns.lineplot()`\n",
310327
"\n",
311328
"## `matplotlib`"
312329
]

0 commit comments

Comments
 (0)