0

I'm looking for a way to plot over an image with predefined fields and get a result like this:

Example 1: Result

I want to build it from:

(1): a PNG image with the fields with predefined x and y limits like this:

PNG with fields

and (2): a scatterplot, e.g.:

mpg %>% 
ggplot() + 
  geom_point(mapping = aes(x = displ, y = hwy, color = class))

Example 2: Scatterplot

Question: How can I do that, ideally referencing/fixing the fields limits to their x and y values? Regards!

1 Answers1

0

I think you have two basic options.

First you could define a custom theme. You might be able to use one of the theming packages. e.g. ggthemr.

Second and probably better, add custom curves which would probably require more work initially depending on how curvy. But would be more flexible in the end. https://ggplot2.tidyverse.org/reference/geom_segment.html

Third probably better still geom_path() https://ggplot2.tidyverse.org/reference/geom_path.html

Fourth use polygons from ggforce. https://luisdva.github.io/rstats/Grouping-points/

Elin
  • 6,507
  • 3
  • 25
  • 47