This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How combine geom-point with geom-line?

I have data like the one below and I would like to draw geom_pint and geom_line together for them (line that links rows together based on study). The geom_point works but line one doesn`t. Also, I would like to put Study below each other than beside each other in the plot (but position=position_dodge(height= 0.6), not working or maybe it is not correct).

e.g: I would like to connect dots together and triangles together.

Thank you in advance for any suggestions!

Input <- data.frame(
                   Study = c("A", "A", "B", "B", "C"),
                   state = c("healthy", "Cov", "healthy", "Cov", "Cov"),
                   variable = c("GHD", "BJD", "GHD", "BJD", "BJD"),
                   log = c(0.80, 1.12, 1.31, 0.73, 1.17),
                   cell = c(0.23000, 0.44000, 0.00073, 0.02500, 0.05600)
                 )

Input:

Study   state    variable           log      cell
  A     healthy     GHD            0.80     0.23000
  A     Cov         BJD            1.12     0.44000
  B     healthy     GHD            1.31     0.00073
  B     Cov         BJD            0.73     0.02500
  C     Cov         BJD            1.17     0.05600
ggplot(Input, aes(x = state, y = variable)) +
                   geom_line(aes(colour = log, size = cell), position = position_dodge(width = 0.6)) +
                   geom_point(aes(shape = Study, colour = log, size = cell, stroke = 3), position = position_dodge(width = 0.6)) +
                   theme_classic()

enter image description here

r ggplot2

Do you have an example plot to show what you're trying to make? Right now your x and y axis values are categorical so it's not obvious how you want the line drawn.

@ rpolicastro Thank you ! plot is added. I want to link dots together and triangles together.

0 answers

No answers yet.

Log in to answer this question.