[英]How do I plot points with two different y-axis ranges on the same panel in the same X axis?
[英]Plot two ranges on y-axis
我正在嘗試編輯y軸,因此它只繪制從-20到100以及從20到100的范圍。這是為了刪除在-25到+25之間發生的大空白空間,因為我沒有繪制數據在這個區域內。
以下是我到目前為止已完成的工作,非常感謝任何人提出的關於如何限制ylim范圍以僅在-100:-20和20:100之間繪制軸的建議
先感謝您
library(plotrix)
pdf("distance2gene.pdf")
data<-read.table("closest_gene_bed.txt",header=FALSE, sep="\t")
DM=data$V5
Distance=data$V15
col.vec=c(rep('olivedrab',length(Distance)))
ind=which(abs(Distance) < 5000)
col.vec[ind]= 'darkorchid4'
opt <- options(scipen = 10)
plot(Distance, DM, col= col.vec, pch = 16, cex =.4,ylim=range(-100,100),xlim=c(-500000,500000))
axis(side = 2, at = c(-100,-75,-50,-25,0,25,50,75,100))
axis.break(axis=2, breakpos=0, brw=0.05, style="slash")
options(opt)
我剛剛看到您正在使用plotrix軟件包:
您正在尋找的功能是?gap.plot
嘗試類似:
library(plotrix)
set.seed(1)
y.up <- runif(100, 20, 100)
y.down <- runif(100, -100, -20)
gap.plot(1:200, c(y.up, y.down), gap=c(-20,20))
希望能幫助到你,
亞歷克斯
使用ggplot
set.seed(1)
y.up <- runif(100, 20, 100)
y.down <- runif(100, -100, -20)
library(ggplot2)
library(reshape2)
df <- data.frame(x=seq_len(100),y.up,y.down)
gg <- melt(df,id="x")
ggplot(gg, aes(x=x,y=value))+geom_point()+facet_grid(variable~.,scales="free")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.