Ggplot2 - line up geom_point with split mailboxes

I am new to R and used Google (mainly directing me to this site) to ruin my path in creating a passive schedule for the project. It’s hard for me to understand what to look for in order to find other people with the same problem as me, so I decided to ask instead.

I have a dataset that looks something like this:

    ATM TEMP PARENT variable value
1     1    5      1     DEAD     2
2     1    5      2     DEAD     0
3     1    5      3     DEAD     1
4     1   20      1     DEAD     1
55    1    5      1     LIVE    47
56    1    5      2     LIVE    42
57    1    5      3     LIVE    45
58    1   20      1     LIVE    45
109   1    5      1 SWIMMING     1
110   1    5      2 SWIMMING     8
111   1    5      3 SWIMMING     4
112   1   20      1 SWIMMING     4

ATM is a pressure experiment conducted at TEMP, PARENT, from which one of the 3 adult larvae came, and the variable represents the state of the larvae at a given pressure / temperature, with the number (initially it was different, but I combined them using reshape2 )

I managed to create this graph:

enter image description here

Using this code:

qplot(factor(ATM), value, data = CONDITION, geom = "boxplot", fill = factor(TEMP)) +
geom_point(aes(colour=factor(TEMP)) +
facet_wrap(~ variable, ncol = 1) +
scale_fill_manual(values = c("lightblue","#FF6666")) +
scale_colour_manual(values = c("lightblue","#FF6666")) +
labs(title = "Effect of Pressure on Condition of C.fornicata Larvae") +
xlab("Pressure \n (atm)") +
ylab("Number of Larvae") +
guides(fill=guide_legend(title="Incubation Temp (°C)"),colour=guide_legend(title="Incubation Temp (°C)"))

, fill=factor(TEMP) ( ), geom_point . position geom_point, .

!

+4
1

?position_dodge.

# Making the example data set bigger    
library(ggplot2)
x = read.table(text='ATM TEMP PARENT variable value
1     1    5      1     DEAD     2
2     1    5      2     DEAD     0
3     1    5      3     DEAD     1
4     1   20      1     DEAD     1
55    1    5      1     LIVE    47
56    1    5      2     LIVE    42
57    1    5      3     LIVE    45
58    1   20      1     LIVE    45
109   1    5      1 SWIMMING     1
110   1    5      2 SWIMMING     8
111   1    5      3 SWIMMING     4
112   1   20      1 SWIMMING     4')
x = rbind(x,x)
x$ATM[13:24] = 50

# Example code that moves the points to the middle of the boxplots
ggplot( aes(x=factor(ATM),y=value), data=x ) +
  geom_boxplot( aes(fill=factor(TEMP))) +
  geom_point( aes(color=factor(TEMP)), 
              position=position_dodge(width=0.75) )

enter image description here

+4

Source: https://habr.com/ru/post/1525995/


All Articles