Rstudent
Rstudent

Reputation: 885

Recreate a plot without data

Is there a way to create a figure similar to the one below without having any data on this?

enter image description here

Upvotes: 2

Views: 455

Answers (2)

Quinten
Quinten

Reputation: 41603

For the arrows you can use this code: arrow = arrow(length = unit(0.5, "cm")) in a geom_segment. It is a bit tricky without any numbers, but maybe you want something like this:

library(ggplot2)
ggplot() + 
  geom_abline(slope = 1) +
  geom_curve(aes(x = 0, y = 0, xend = 1, yend = 1), curvature = -0.4) +
  geom_curve(aes(x = 0, y = 1, xend = 1, yend = 0.1), curvature = 0.4, linetype = "dashed") +
  geom_segment(aes(x=0.9,y=0.98,xend=0.9,yend=0.12), arrow = arrow(length = unit(0.5, "cm"))) +
  geom_segment(aes(x=0.02,y=0.85,xend=0.02,yend=0.23), arrow = arrow(length = unit(0.5, "cm"))) +
  annotate("text", x = 0.5, y = 0.5, label = "Line of Equality", angle = 45, vjust = 2) +
  annotate("text", x = 0.25, y = 0.75, label = "Income (etc.)", angle = 45, vjust = 2) +
  annotate("text", x = 1.2, y = 0.1, label = "Corresponding\nExposure", angle = 0) +
  labs(x = "Individuals Neighbourhoods\nAcross Space", y = "Scoioeconomic Position") +
  scale_x_continuous(limits = c(0, 1.3)) +
  theme_minimal() +
  theme(axis.text = element_blank())

Output:

enter image description here

Upvotes: 2

Carl
Carl

Reputation: 7540

You could do something like this. You could add another geom_curve and a couple of geom_vlines.

library(tidyverse)

ggplot() +
  geom_abline() +
  geom_curve(aes(x = 0, y = 0, xend = 1, yend = 1), curvature = -0.4) +
  annotate("text", x = 0.5, y = 0.5, label = "Line of Equality", angle = 35, vjust = 2) +
  labs(x = "Individuals Neighbourhoods\nAcross Space", y = "Scoioeconomic Position") +
  theme_minimal() +
  theme(axis.text = element_blank())

Created on 2022-04-27 by the reprex package (v2.0.1)

Upvotes: 6

Related Questions