Which aesthetic names? Opinions please!
Which aesthetic names shall we use in tmap v4?
We could (of course) use the same as in the current version, but there will be (small) inconsistencies between layers. Moreover, many visual variables have not been implemented as aesthetic yet (e.g. alpha and line type). Some have not even implemented as visual constants (e.g. border line type for polygons).
Ideally, I would like to standardize aesthetic names, so not decide per layer function, but in general. Below a proposal based on a table that @Nowosad made earlier (thanks!). I only considered the elementary layers:
| layer | aes | other_aes* |
|---|---|---|
| tm_polygons() | fill, color, pattern, linetype, linewidth, fill.alpha, color.alpha | linejoin |
| tm_symbols() / tm_dots()* | fill, color, pattern, linetype, linewidth, fill.alpha, color.alpha, size | |
| tm_lines() | color, linetype, linewidth | linejoin, lineend |
| tm_arrow()* | color, linetype, linewidth, orientation, curvature | lineend, arrowhead |
| tm_raster() or tm_hex() | color | |
| tm_text() | text, color, size, fontfamily, fontface |
Remarks:
- The category
other_aeswill be visual constants and not visual variables, as I see no use in having a data variable encoded as e.g. linejoin. - I included the
tm_arrowsince it has additional aesthetics. For now, I only considertm_linesto be used for paths andtm_arrowfor (curved) origin destination arrows. There are many alternatives possible, e.g. bundles edges but these may follow later. -
tm_dotsandtm_symbolsboth usecoloras line color andfillas fill color. However, many symbols do not have a fill, so their color is controlled bycoloronly. This applies to dots withpch=16. - A
tm_cartogramwill be the same astm_polygonswith an additionalsizeaesthetic. Note that a non contiguous cartogram is in essence similar to tm_symbols. Contiguous cartograms and dorling cartograms have more intelligence under the hood, but again, these only require the additionalsizeaesthetic.
Some choices to make:
-
colorcolor? -
lwd(current tmap),linewidth, orstroke(ggplot2)? -
orientationordirectionfortm_arrows? - alternatives for
fill.alphaandcolor.alpha?
Shoot!
I suggest always prefer the argument names used in base R if they exist. col, lty, lwd, and similar are transferable between packages (including mapsf), grid and graphics, see ?grid::gpar and ?graphics::par. Possiibly prefer gpar() versions if grid and graphics diverge.
Good point! And that's also consistent with the current version of tmap. Small downside is that the other required aesthetic names like size, orientation (or direction) are currently not abbreviated. The base R variant for size is cex, but that is not a very user friendly parameter name.
Would be great if col, color and colour were all valid (as they are in ggplot I believe?)
linewidth preferably to lwd or stroke in my opinion.
- Does it make sense to have fontfamily and fontface as visual variables? Are they not better as visual constants?
-
lwdis fine by me. - What would the
orientation/directionspecify fortm_arrows()? -
fill.alphaandcolor.alphaare fine.. -
colorcoloris probably the most debatable decision. (Correct me if I am wrong) Base Rcolrelates (depending on a plot) to the colors of the objects or to the fill of the objects. In tmap, it would be preferable to split color from fill. If it would be possible to use bothcolandcolor- that would be great. If not, I do not have any clear preferences...
@Nowosad good questions.
-
fontfamilynot sure, butfontfaceis useful, e.g. for topographical maps which differentiate capitals from other cities. -
linewidthis also fine with me, but I have a slight preference myself for shorter, abbreviated names (lwdoverlinewidth). - Not sure yet, but in some designs there is no arrowhead but a gradient which indicates direction. Although the coordinates already specify the direction (so a data variable is not always needed), a legend is still useful. But we have to give this more thought.
- For single-color layers, such as
tm_linesandtm_raster, I would prefer to usealpha. Probably, this won't be a problem. Perhaps we should replace the dots by underscores (see below). - Yes, indeed good to split "area" color from "stroke" color. It makes sense to call the former
filland the lattercol.- It is slightly inconsistent with the current version, since
tm_polygonscurrently usescolandborder.col. However, we can make it backwards compatible as follows: when a user runstm_polygons(col = "x"), it will be interpreted astm_polygons(fill = "x")with a message thatcolis interpreted asfill, which will be the case in 99.99% of the applications. For users who really want to use the border color as aesthetic we can add a tmap option likeautocorrect.arguments, that disables this behavior. - Whether
tm_rasteris afillorcolis debatable. On the one hand it is afill, since a raster tile occupies a certain area. On the other hand, it has no stroke so one can argue that a tile itself is some sort of squared (or hex) symbol. I would go for the latter explanation, so usecol, since it is more intuitive name thanfill.
- It is slightly inconsistent with the current version, since
As it is implemented in v4 for now, each aesthetic will have 4 arguments:
- The aesthetic itself, e.g.
col. - The setup,
col.setup, is a list that contains settings for this aesthetic which were previously loose arguments (e.g.styleandbreaks). - The (general) legend settings
col.legend, such as legend title and orientation (portrait or landscape). - A logical
col.freewhich determines whether this aesthetic should be processed per facet or for all facets at once.
The names fill.alpha and col.alpha also contain dots, which is a bit confusing. We could opt for fill_alpha and color_alpha instead.