3

I came across this question which had a really cool graph . I am interested in the graphs on the left with the rectangular points across time.

These rectangular points are not part of R's default set of points to give the geom_point() command. While I can reproduce the graph (or at least one very similar) I don't know how to get the points to look like that.

How can I achieve this?

enter image description here

Community
  • 1
  • 1
G_T
  • 1,555
  • 1
  • 18
  • 34

3 Answers3

5

It seems to me that's just geom_tile, not geom_point in target plot.

require("ggplot2")

ggplot(iris) + geom_tile(aes(x = Sepal.Length, y = Sepal.Width, 
                             fill = Petal.Length), color = "white") + 
  facet_grid(Species ~ .) + 
  scale_fill_gradient(low = "red3", high = "blue4")

enter image description here

inscaven
  • 2,514
  • 19
  • 29
1

While not exactly what you are after, you can change the plotting shapes with scale_shape_manual() ie

d <- ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species, shape = Species))
d <- d + geom_point()
d + scale_shape_manual(values = c(15, 15, 15))

enter image description here

aeongrail
  • 1,304
  • 1
  • 13
  • 26
  • Thank you but `scale_shape_manual()` allows you to set the sequence of shapes used in ggplot but not introduce new shapes (or alter existing ones) which is what I believe I'm looking for. – G_T Feb 19 '16 at 03:48
1

You should be able to do this with geom_rect:

library(ggplot2)
df <- data.frame(x = c(1,2,3), y = c(1,2,1), type = c("a","b","c"))
ggplot(df) +
  geom_rect(aes(xmin = x, ymin = y, xmax = x + 0.3, ymax = y + 0.6, fill = type))
Mist
  • 1,888
  • 1
  • 14
  • 21