将ggbio跟踪标签更改为水平

时间:2014-08-21 12:42:44

标签: r ggplot2 bioconductor

在基础R图中,我们有las选项来旋转轴标签。

有没有办法让标签time1time2成为横向,从tracks() function开始使用ggbio package

require(ggplot2)
require(ggbio)

## make a simulated time series data set
df1 <- data.frame(time = 1:100, score = sin((1:100)/20)*10)
p1 <- qplot(data = df1, x = time, y = score, geom = "line")
df2 <- data.frame(time = 30:120, score = sin((30:120)/20)*10, value = rnorm(120-30 + 1))
p2 <- ggplot(data = df2, aes(x = time, y = score)) + 
  geom_line() + geom_point(size = 4, aes(color = value))

#plot
tracks(time1 = p1,time2 = p2)

enter image description here

1 个答案:

答案 0 :(得分:0)

ggbio函数似乎不包含此选项。你可以做自己的ggplot。

df1$value = NA
df1$times = "time1"
df2$times = "time2"
df3 = rbind(df1, df2)

ggplot(data = df3, aes(x = time, y = score)) + 
  facet_grid(times~.) +
  geom_line() + 
  geom_point(size = 4, aes(color = value)) +
  theme(strip.text.y = element_text(angle = 0))

您仍然可以选择以SVG格式保存track图并使用Inkscape编辑SVG文件。