Skip to content

Commit 3c2d06a

Browse files
committed
short section about Matplotlib and pandas DataFrames
1 parent 1e97b36 commit 3c2d06a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

content/data-visualization.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ From [Claus O. Wilke: "Fundamentals of Data Visualization"](https://clauswilke.c
3535
high-level interface to Matplotlib, statistical functions built in
3636
- [Vega-Altair](https://altair-viz.github.io/gallery/index.html):
3737
declarative visualization, statistics built in
38+
(we have an [entire lesson about data visualization using Vega-Altair](https://coderefinery.github.io/data-visualization-python/))
3839
- [Plotly](https://plotly.com/python/):
3940
interactive graphs
4041
- [Bokeh](https://demo.bokeh.org/):
@@ -402,6 +403,7 @@ ax.tick_params(labelsize=15)
402403
high-level interface to Matplotlib, statistical functions built in
403404
- [Vega-Altair](https://altair-viz.github.io/gallery/index.html):
404405
declarative visualization, statistics built in
406+
(we have an [entire lesson about data visualization using Vega-Altair](https://coderefinery.github.io/data-visualization-python/))
405407
- [Plotly](https://plotly.com/python/):
406408
interactive graphs
407409
- [Bokeh](https://demo.bokeh.org/):
@@ -509,6 +511,28 @@ clarify questions at this point before moving on.
509511

510512
---
511513

514+
## Matplotlib and pandas DataFrames
515+
516+
In the above exercises we have sent individual columns of the `gapminder_data` DataFrame
517+
into `ax.scatter()` like this:
518+
```python
519+
fig, ax = plt.subplots()
520+
521+
ax.scatter(x=gapminder_data["gdpPercap"], y=gapminder_data["lifeExp"], alpha=0.5)
522+
```
523+
524+
It is possible to do this instead and let Matplotlib "unpack" the columns:
525+
```python
526+
fig, ax = plt.subplots()
527+
528+
ax.scatter(x="gdpPercap", y="lifeExp", alpha=0.5, data=gapminder_data)
529+
```
530+
531+
Other input types are possible. See [Types of inputs to plotting
532+
functions](https://matplotlib.org/stable/users/explain/quick_start.html#types-of-inputs-to-plotting-functions).
533+
534+
---
535+
512536
```{keypoints}
513537
- Minimize manual post-processing, script everything.
514538
- Browse a number of example galleries to help you choose the library

0 commit comments

Comments
 (0)