简体   繁体   中英

plotting coverage to its values in R

I am having some doubts in plotting x axis that has two values to the y axis.

My data:

Start End Value

20     50   0.45
50     75   0.67
75     100  1.99
...    ....  N

Now I would like to plot x axis with its range (ie 25-50 and its corresponding value) instead of taking a single variable (25 or 50).

So the plot would be something like this:

目标情节

Sounds like this is what you want:

df <- data.frame(start=c(20,50,75,150), end=c(50,75,150,250), value=c(0.45,0.67,1.99,1.5) );
df;
##   start end value
## 1    20  50  0.45
## 2    50  75  0.67
## 3    75 150  1.99
## 4   150 250  1.50
xtick <- seq(floor(min(df$start)/10)*10,ceiling(max(df$end)/10)*10,10);
ytick <- seq(0,ceiling(max(df$value)),0.1);
par(xaxs='i',yaxs='i');
plot(NA,xlim=c(min(xtick),max(xtick)),ylim=c(min(ytick),max(ytick)),axes=F,xlab='',ylab='');
rect(df$start,0,df$end,df$value,col=1:nrow(df));
axis(1,xtick);
axis(2,ytick);

情节

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM