Closed alistaire47 closed 6 years ago
The lineend
setting is hardcoded here:
https://github.com/tidyverse/ggplot2/blob/5f868c598e88c7096896c0c8c37cbd34a3fb8e47/R/sf.R#L210
To make it configurable, it needs to be made an argument of the draw_panel()
function:
https://github.com/tidyverse/ggplot2/blob/5f868c598e88c7096896c0c8c37cbd34a3fb8e47/R/sf.R#L154
and then passed through to sf_grob()
:
https://github.com/tidyverse/ggplot2/blob/5f868c598e88c7096896c0c8c37cbd34a3fb8e47/R/sf.R#L189
(and maybe the same should be done for the linejoin
and linemitre
parameters).
The draw_panel()
function from GeomPath
can serve as an example:
https://github.com/tidyverse/ggplot2/blob/5f868c598e88c7096896c0c8c37cbd34a3fb8e47/R/geom-path.r#L143-L145
Do you want to prepare a pull request?
And if you want to document these parameters and their default settings, you should add them to the constructor functiongeom_sf()
as well, as can be seen here for geom_path()
:
https://github.com/tidyverse/ggplot2/blob/5f868c598e88c7096896c0c8c37cbd34a3fb8e47/R/geom-path.r#L90-L117
Ok! It's a busy week, but you've left a good path here, so with a little luck I should be able to get this together relatively quickly.
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/
Due to this SO question, I discovered that while
geom_sf
does pass aesthetics through to the appropriate layer (here to plot linestrings as paths), e.g.size
, it doesn't pass parameters likelineend
,linemitre
,linejoin
, andarrow
, which are parameters ofgeom_path
, not aesthetics likesize
orlinetype
. In this case, this makes getting rid of the gaps in this plot harder:According to
?geom_sf
, these parameters get passed through...
to the paired geom/stat orlayer
, though that function doesn't have parameters for everything or dots—I'm assuming they're passed to itsparams
parameter. The problem here seems to be that the paired stat here isstat_sf
, which does not have the specified parameters and is not passing them along further.Ultimately this behavior is a product of the fact that
geom_sf
dispatches to so many...geoms? As a sort of meta-geom it's more strongly opinionated than the rest of the API, making it hard to, say, use sf points as locations forgeom_text
without pulling out the coordinates. Guidance in the docs on what sf geometry type dispatches to what geom (?) (and whether there's a way to override that dispatching) and thus what parameters can be passed would be welcome.