Skip to content

Commit

Permalink
ch08 comments
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldorman committed Nov 5, 2023
1 parent 4334d63 commit 38a43be
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 46 deletions.
12 changes: 7 additions & 5 deletions 08-mapping.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ We can set symbology in a `.plot` using the following parameters:

- `column`---a column name
- `legend`---whether to show a legend
- `cmap`---color map
- `cmap`---color map, a.k.a. color scale, a palette from which the colors are sampled
<!-- jn: what's color map? what does it mean? You use term color scale later... -->
<!-- md: these are interchangeable, now clarified -->

For example, @fig-plot-symbology shows the `nz` polygons colored according to the `'Median_income'` attribute (column), with a legend.

Expand All @@ -173,14 +174,15 @@ The following code sections demonstrates three color scale specifications other
#| fig-subcap:
#| - The `'Reds'` color scale from ColorBrewer
#| - Reversed `'Reds'` color scale
#| - The `'spring'` color scale from **matplotlib**
#| - The `'plasma'` color scale from **matplotlib**
#| layout-ncol: 3
nz.plot(column='Median_income', legend=True, cmap='Reds');
nz.plot(column='Median_income', legend=True, cmap='Reds_r');
nz.plot(column='Median_income', legend=True, cmap='spring');
nz.plot(column='Median_income', legend=True, cmap='plasma');
```

<!-- jn: spring does not look like a color blind friendly color scale... I would suggest to use a different one. (I would suggest avoiding giving bad examples, even if they are just examples...) -->
<!-- md: sure, I replaced with another color scale which seems more recommended, will be happy for other suggestions -->

Categorical symbology is also supported, such as when `column` points to an `str` attribute.
For categorical variables, it makes sense to use a qualitative color scale, such as `'Set1'` from ColorBrewer.
Expand Down Expand Up @@ -209,10 +211,10 @@ The `rasterio.plot.show` function is also based on **matplotlib**, and thus supp
#| fig-subcap:
#| - The `'BrBG'` color scale from ColorBrewer
#| - Reversed `'BrBG_r'` color scale
#| - The `'nipy_spectral'` color scale from **matplotlib**
#| - The `'gist_earth'` color scale from **matplotlib**
rasterio.plot.show(nz_elev, cmap='BrBG');
rasterio.plot.show(nz_elev, cmap='BrBG_r');
rasterio.plot.show(nz_elev, cmap='nipy_spectral');
rasterio.plot.show(nz_elev, cmap='gist_earth');
```

Unfortunately, there is no built-in option to display a legend in `rasterio.plot.show`.
Expand Down
82 changes: 41 additions & 41 deletions output/plot_rasterio2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 38a43be

Please sign in to comment.