0

I am trying to customized the geom_point plot and I've attached my dataset example below.

# Example of the data
library(ggplot2)
coverage = data.frame("category" = c("A","A","B","B","C","C"), "position" = c(1,4,1,3,2,3), "width" = c(10,4,5,7,2,20))
ggplot(test1, aes(x=position, y=width)) + geom_point(colour="red", size=10, shape=20, alpha=1/3)

when I executed this code, I obtained following images

enter image description here

As you can see the above image, if the position information overlapped, the width value represent the same position, this image was not reflected "category" variable. so, I want to take a image that ordered by "category" value like this images.

enter image description here

How can I setting the options?

Park
  • 14,771
  • 6
  • 10
  • 29

1 Answers1

0

Using facet_wrap()

ggplot(coverage, aes(x=position, y=width)) + geom_point(colour="red", size=10, shape=20, alpha=1/3) +
  facet_wrap(.~category)

enter image description here

Park
  • 14,771
  • 6
  • 10
  • 29
  • Thank you for your rapid answer! It's really helpful to me :) Can I have one more question?? Actually, I want to plot my origin data following the same method. This data has a 2,918,063,992 lines information, about 52GB file size. If I have a plenty of time and memory, Is it possible to draw the image ? – Henry Chiles Sep 09 '21 at 07:52
  • @HenryChiles I'm very cautious with plot about 2.9e8 size data with R. Possibility might depends on type of plot you want. – Park Sep 09 '21 at 08:17
  • @HenryChiles the output will be very cluttered if you want a similar graph like this one. Though it depends largely on the scope of your problem, I think it will be best to take a random sample of the data and then plot it. – Shibaprasadb Sep 09 '21 at 08:20