0

I'm trying to plot data for research. It should look like this,

Segment plot

This was drawn with R. I was wondering if there is any way to draw something like this in Python? Each segment has their own start and end from 2 variables that are in x. y is just the IDs of the samples.

Here is the R code,

df <- read.table("df.hom",header=T,stringsAsFactors = F)

p1 <- ggplot(df[which(df$PHE == 2),])

p1 <- p1 + geom_segment(aes(x=POS1, xend=POS2, y=IID, yend=IID), size=5)

p1 <- p1 + xlab("Position (in Mb)") + ylab("Sample")

p1 <- p1 + theme_bw()

p1
Nelewout
  • 6,281
  • 3
  • 29
  • 39
Marko
  • 1
  • Have a look [here](https://stackoverflow.com/questions/21352580/matplotlib-plotting-numerous-disconnected-line-segments-with-different-colors) – Christoph Aug 18 '18 at 14:41
  • What have you tried so far that doesn't work for you? – Roman Luštrik Aug 18 '18 at 15:09
  • I tried https://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#segments-and-rays but with no luck, every time I get this error : "Glyph refers to nonexistent column name" and I get an empty plot. – Marko Aug 21 '18 at 19:40

0 Answers0