Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update layout and description text for ggplot2 comparison vignette #980

Merged
merged 1 commit into from
Dec 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions vignettes/03_versus_ggplot2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ data(World, metro, rivers, land)
#tmap_design_mode()
```

## Choropleth Map comparision

## Choropleth
An example of how the default output of `tmap` compares with `ggplot2`.

This is the default output of `ggplot2`:

```{r}
library(ggplot2)
Expand All @@ -65,6 +68,8 @@ ggplot(World) +
```


This is the default output of `tmap`:

```{r}
tm_shape(World, crs = "+proj=eqearth") +
tm_polygons(fill = "HPI",
Expand All @@ -73,12 +78,17 @@ tm_shape(World, crs = "+proj=eqearth") +
fill.scale = tm_scale_continuous(values = "pu_gn", midpoint = 35))
```

Note the different line width values. The unit of a line width is different. tmap follows the lwd parameter (see [graphics::par]) whereas in ggplot2 `linewidth = 1` equals roughly 0.75 [due to a historical error](https://ggplot2.tidyverse.org/articles/ggplot2-specs.html#linewidth)
Note the different line width values:

- `linewidth = .4` in `ggplot2`
- `lwd = 1` in `tmap`

The unit of a line width is different. `tmap` follows the `lwd` parameter (see [`graphics::par`](https://www.rdocumentation.org/packages/graphics/versions/3.6.2/topics/par)) whereas in `ggplot2` `linewidth = 1` equals roughly 0.75 [due to a historical error](https://ggplot2.tidyverse.org/articles/ggplot2-specs.html#linewidth).


## Mimicking ggplot2 layout

Using tmap to match the style of ggplot2:
We can use `tmap` to match the style of `ggplot2`:

```{r}
tm_shape(World, crs = "+proj=eqearth") +
Expand Down
Loading