0

In my dataset I have 2 continuous variables (A1BG and A2LD1) and 1 categorical (Class).

I'm trying to plot A1BG and A2LD1 and color coding by class which is good so far.

however, how to differentiate between A1BG and A2LD1 by shape?

Here's my code so far..

ggplot(RNA, aes(x = A1BG,
             y = A2LD1,
             col = Class,
            main = "Relationship Between A1BG and A2LD1")) + geom_point()+ theme(panel.grid =element_blank(),
                  panel.background = element_rect(fill = "white"),
                  panel.border = element_rect(colour = "black",
                                              fill = NA, size = 0.2))

Sample Data:

(A1BG = c(5.620562952, 7.591106401, 8.348814005, 7.399435165, 7.494443613, 7.005119237, 7.825150239, 9.84125156, 7.711686244, 8.019511781),A2LD1 = c(5.243981286, 6.148334212,7.334008637, 6.853456781, 7.026735889, 5.723555831, 7.032773092, 5.538007298, 6.077351966, 6.283886593), Class = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
Khawlah
  • 1
  • 1
  • Add `shape = Class` within `aes()`. – Phil Nov 29 '21 at 15:00
  • I can't understand your example without sample data. It looks like A1BG is the x-axis coordinate, and A2LD1 is the y-axis coordinate, both corresponding to a single point (each row). Every point has an x and y coordinate. Every point has a A1BG value and a A2LD1 value, so how would the shape differentiate these two coordinates for a single point? – Gregor Thomas Nov 29 '21 at 15:06
  • Please share some sample data, e.g. `dput(RNA[1:10, ])` for a copy/pasteable version of the first 10 rows of RNA including all class and structure information. And also please clarify your request. – Gregor Thomas Nov 29 '21 at 15:07
  • structure(list(A1BG = c(5.620562952, 7.591106401, 8.348814005, 7.399435165, 7.494443613, 7.005119237, 7.825150239, 9.84125156, 7.711686244, 8.019511781), A2LD1 = c(5.243981286, 6.148334212, 7.334008637, 6.853456781, 7.026735889, 5.723555831, 7.032773092, 5.538007298, 6.077351966, 6.283886593), Class = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), row.names = c(NA, -10L), class = c("tbl_df", "tbl", "data.frame")) – Khawlah Nov 29 '21 at 15:15
  • Sorry I am not sure if this is the correct way of sharing the sample in here. Please let me know if it's better done some way else. – Khawlah Nov 29 '21 at 15:17
  • I have already colored the points based on class, what I want is to have different shapes for each variable. For example: Circle for A1BG and rectangular for A2LD1 while all colored based on class (coloring is done already) – Khawlah Nov 29 '21 at 15:23
  • You should add your data into the question, not as a comment. If you have a spare moment: [Link for guidance on asking questions](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Peter Nov 29 '21 at 16:52
  • I have added a sample Data FYR as requested – Khawlah Dec 01 '21 at 20:05

0 Answers0