{
"cells": [
{
"cell_type": "markdown",
"id": "fb7fec6d-8d14-4ab0-8e15-a05eb7db28da",
"metadata": {},
"source": [
"# matplotlib - Advanced Layouts"
]
},
{
"cell_type": "markdown",
"id": "62bf5cc9-b71b-45bd-a709-77d3b2bd3059",
"metadata": {},
"source": [
":::{admonition} Learning Objectives\n",
"* Be able to use matplotlib's `.subplot()` to layout plots in regular grid arrangements.\n",
"* Be able to use matplotlib's `.subplot2grid()` to create more advanced layouts with plots spanning more than one \"grid space.\"\n",
":::"
]
},
{
"cell_type": "markdown",
"id": "904c3d2a-b5a7-4e71-a943-6fa34e34d40a",
"metadata": {},
"source": [
":::{important} \n",
"Much of the information and many of the figures in this notebook come from: \"Python Plotting With Matplotlib (Guide)\" written by *Brad Solomon* and published on realpython.com at https://realpython.com/python-matplotlib-guide. The website [realpython.com](https://realpython.com/) is a great way to learn python and is filled with resources. \n",
":::"
]
},
{
"cell_type": "markdown",
"id": "68d7a93a-e479-49b6-90b4-81973c4cf869",
"metadata": {},
"source": [
"(3114:05:data-file-for-lesson)=\n",
"## Data File for Lesson"
]
},
{
"cell_type": "markdown",
"id": "d1bb1cf1-0e10-4798-8850-3f8565985499",
"metadata": {},
"source": [
"You will need the following data file for this lesson: \n",
"[cal_housing.data](https://drive.google.com/uc?id=1l4YCgMuYTx4y4ax7uUcHevYbOVlYtajx&export=download) \n",
"Pace, R. Kelley, and Ronald Barry, \"Sparse Spatial Autoregressions,\" Statistics and Probability Letters, Volume 33, Number 3, May 5 1997, p. 291-297."
]
},
{
"cell_type": "markdown",
"id": "ffa47578-a487-4c4d-82c2-8eb2165d50c1",
"metadata": {},
"source": [
"A description of the data columns included in this dataset are reprinted below."
]
},
{
"cell_type": "markdown",
"id": "1662b21d-0944-4ebe-b6f9-72a42b1337d2",
"metadata": {
"tags": []
},
"source": [
"```{figure} ../images/housing_data_description.png \n",
":height: 900px\n",
":name: Calif_dataset \n",
" \n",
"Reprinted from https://developers.google.com/machine-learning/crash-course/california-housing-data-description \n",
"```"
]
},
{
"cell_type": "markdown",
"id": "b32b3c3a-5b16-4f83-9ee7-24fb2f112d1f",
"metadata": {
"tags": [
"remove-cell"
]
},
"source": [
""
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "8754fdbf-9b05-4488-9d79-0552d56e6cfb",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n", " | longitude | \n", "latitude | \n", "housingMedianAge | \n", "totalRooms | \n", "totalBedrooms | \n", "population | \n", "households | \n", "medianIncome ($10,000) | \n", "medianHouseValue ($) | \n", "
---|---|---|---|---|---|---|---|---|---|
0 | \n", "-122.23 | \n", "37.88 | \n", "41.0 | \n", "880.0 | \n", "129.0 | \n", "322.0 | \n", "126.0 | \n", "8.3252 | \n", "452600.0 | \n", "
1 | \n", "-122.22 | \n", "37.86 | \n", "21.0 | \n", "7099.0 | \n", "1106.0 | \n", "2401.0 | \n", "1138.0 | \n", "8.3014 | \n", "358500.0 | \n", "
2 | \n", "-122.24 | \n", "37.85 | \n", "52.0 | \n", "1467.0 | \n", "190.0 | \n", "496.0 | \n", "177.0 | \n", "7.2574 | \n", "352100.0 | \n", "
3 | \n", "-122.25 | \n", "37.85 | \n", "52.0 | \n", "1274.0 | \n", "235.0 | \n", "558.0 | \n", "219.0 | \n", "5.6431 | \n", "341300.0 | \n", "
4 | \n", "-122.25 | \n", "37.85 | \n", "52.0 | \n", "1627.0 | \n", "280.0 | \n", "565.0 | \n", "259.0 | \n", "3.8462 | \n", "342200.0 | \n", "
\n", " | longitude | \n", "latitude | \n", "housingMedianAge | \n", "totalRooms | \n", "totalBedrooms | \n", "population | \n", "households | \n", "medianIncome ($10,000) | \n", "medianHouseValue ($) | \n", "
---|---|---|---|---|---|---|---|---|---|
0 | \n", "-122.23 | \n", "37.88 | \n", "41.0 | \n", "880.0 | \n", "129.0 | \n", "322.0 | \n", "126.0 | \n", "8.3252 | \n", "452600.0 | \n", "
1 | \n", "-122.22 | \n", "37.86 | \n", "21.0 | \n", "7099.0 | \n", "1106.0 | \n", "2401.0 | \n", "1138.0 | \n", "8.3014 | \n", "358500.0 | \n", "
2 | \n", "-122.24 | \n", "37.85 | \n", "52.0 | \n", "1467.0 | \n", "190.0 | \n", "496.0 | \n", "177.0 | \n", "7.2574 | \n", "352100.0 | \n", "
3 | \n", "-122.25 | \n", "37.85 | \n", "52.0 | \n", "1274.0 | \n", "235.0 | \n", "558.0 | \n", "219.0 | \n", "5.6431 | \n", "341300.0 | \n", "
4 | \n", "-122.25 | \n", "37.85 | \n", "52.0 | \n", "1627.0 | \n", "280.0 | \n", "565.0 | \n", "259.0 | \n", "3.8462 | \n", "342200.0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
20635 | \n", "-121.09 | \n", "39.48 | \n", "25.0 | \n", "1665.0 | \n", "374.0 | \n", "845.0 | \n", "330.0 | \n", "1.5603 | \n", "78100.0 | \n", "
20636 | \n", "-121.21 | \n", "39.49 | \n", "18.0 | \n", "697.0 | \n", "150.0 | \n", "356.0 | \n", "114.0 | \n", "2.5568 | \n", "77100.0 | \n", "
20637 | \n", "-121.22 | \n", "39.43 | \n", "17.0 | \n", "2254.0 | \n", "485.0 | \n", "1007.0 | \n", "433.0 | \n", "1.7000 | \n", "92300.0 | \n", "
20638 | \n", "-121.32 | \n", "39.43 | \n", "18.0 | \n", "1860.0 | \n", "409.0 | \n", "741.0 | \n", "349.0 | \n", "1.8672 | \n", "84700.0 | \n", "
20639 | \n", "-121.24 | \n", "39.37 | \n", "16.0 | \n", "2785.0 | \n", "616.0 | \n", "1387.0 | \n", "530.0 | \n", "2.3886 | \n", "89400.0 | \n", "
20640 rows × 9 columns
\n", "