0

ggpairs provide graph with two box plots connecting points to show before and after situation after giving an intervention.

  1. Want to change y axis label "Resist" "Suscept" instead of "3GCr" and "3GCs".

  2. And want to change data point with r default shape like Resist= circle (1) & Suscept= Diamond(5)

Searched several sites but not get the desired result. Also add code and output:

df.reach.sub <- data.frame(Resist = c(5.78, 3.85, 5.60, 7.83, 6.68, 7.90), Suscept =c(5.70, 3.70, 8.82, 8.67, 9.06, 8.08), Age = c(1,1,1,1,1,1), Status = c("Positive", "Positive", "Positive", "Positive", "Positive", "Positive"))

df.reach.subCat1 <- df.reach.sub[which(df.reach.sub$Age == "1-3" & df.reach.sub$Status == "Positive"),]
gp.plotCat1 <- ggpaired(df.reach.subCat1, cond1 = "Resist", cond2 = "Suscept", color = "Black", line.color = "gray", line.size = 0.4, palette = "npg", ylab = expression('log'[10]*' CFU / g faeces'), xlab = NULL, main = expression("A) 1-3 months ("*italic('p = 0.116, n = 6')*')'), legend = "none", ggtheme = theme_bw(), ylim = c(2,10))

gp.plotCat1

tjebo
  • 21,977
  • 7
  • 58
  • 94
  • 1
    Welcome to SO. Please provide an MCVE ([here](https://stackoverflow.com/help/mcve)), this will help us to help you. – tjebo Aug 09 '18 at 06:46
  • how can I upload data or part of data – Md. Rayhanul Islam Aug 09 '18 at 07:50
  • have a look at this thread : https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. the best is to take a bit of time and create a new , minimal dataset (or use one of the inbuilt ones) – tjebo Aug 09 '18 at 07:58
  • Thanks. I have updated and now i think it looks good – Md. Rayhanul Islam Aug 09 '18 at 08:54
  • your question 1) is unclear to me. Your y-axis is not labelled as you have suggested. Question 2) A look into the ggpairs documentation suggests that you might be able to do this changing the `mapping` argument. On the other hand, your plot could easily be done with `ggplot2` only. Maybe this could be an option for you – tjebo Aug 12 '18 at 11:45
  • @Tjebo I know ggplot2 is another good option but want to do this ggpaired. Also checked ggpaires doc but could not find anything to change x axis and value label shape change. – Md. Rayhanul Islam Aug 13 '18 at 08:15

1 Answers1

0

I recommend to use some tidyverse and "basic" ggplot2, like this

df.reach.sub %>% 
  rownames_to_column() %>% 
  gather(key, value, -Age, -Status, -rowname) %>% 
  ggplot(aes(key, value)) +
    geom_boxplot() + 
    geom_point(aes(shape=key), show.legend = F, size=2) + 
    geom_path(aes(group=rowname)) + 
    theme_bw()

enter image description here

Roman
  • 17,008
  • 3
  • 36
  • 49