0

I seen this figure and am not very sure how it was generated with the 'x' and 'o' values which are plotted for '1' and '0'.

enter image description here

Does any body have a clue into how to make this?

Allan Cameron
  • 147,086
  • 7
  • 49
  • 87
bvowe
  • 3,004
  • 3
  • 16
  • 33
  • 3
    Use `geom_point()` with a `shape=` aesthetic. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick May 19 '20 at 18:23

2 Answers2

4

To make @MrFlick's suggestion a bit more concrete, here's a reprex that comes close to recreating the plot you posted:

library(ggplot2)

set.seed(81)
df <- data.frame(x = rexp(200, 1/250), 
                 y = rexp(200, 1/250), 
                 value = c("O", "X"), stringsAsFactors = FALSE)

ggplot(df, aes(x, y, colour = value, shape = value)) +
  geom_point(size = 4, alpha = 0.5) +
  scale_shape_identity() +
  scale_colour_manual(values = c("dodgerblue", "red")) +
  geom_rug(colour = "gray30", sides = "b") +
  labs(x = "", y = "") +
  scale_y_continuous(breaks = 1:3 * 500) +
  theme_bw() + 
  theme(legend.position = "none", 
        axis.text.x = element_blank(),
        text = element_text(size = 20),
        axis.line = element_line(size = 1))

enter image description here

Allan Cameron
  • 147,086
  • 7
  • 49
  • 87
1

There is a lot of documentation on geom_point() points's shapes, for example here.
Happy reading!

enter image description here

Jrm_FRL
  • 1,394
  • 5
  • 15