2013-03-07 60 views
0

数据集1变化x轴:如何把多个图形中相同的曲线图具有相同的Y AIX的范围,但作为R

0.8519685 1 
0.8400882 1 
0.8464 1 
0.8428793 1 
0.8438172 1 
0.8416375 1 
0.8475025 1 
0.8296616 1 
0.8415241 1 
0.8577903 1 
0.8654286 1 
0.8591148 1 
0.8352778 1 
0.8508564 1 
0.8199912 1 
0.8440318 1 
0.8161487 1 
0.8592727 1 
0.850286 1 
0.8563889 1 
0.8585333 1 
0.854275 1 
0.8418394 1 
0.8315148 1 
0.8040112 2 
0.7881706 2 
0.78821 2 
0.7818517 2 
0.7773207 2 
0.7817786 2 
0.769675 2 
0.7681707 2 
0.7568771 2 
0.7822226 2 
0.7774829 2 
0.7894815 2 
0.7744519 2 
0.7782154 2 
0.7394333 2 
0.7749136 2 
0.7497919 2 
0.7928364 2 
0.7887512 2 
0.8072222 2 
0.78303 2 
0.8209792 2 
0.7590879 2 
0.7787667 2 
0.8447202 3 
0.8406627 3 
0.831145 3 
0.8319397 3 
0.8370069 3 
0.8103875 3 
0.8024688 3 
0.8127556 3 
0.8072374 3 
0.8147936 3 
0.8389314 3 
0.8404519 3 
0.8145204 3 
0.8214462 3 
0.7823491 3 
0.8034705 3 
0.7878973 3 
0.8193091 3 
0.8240977 3 
0.8301389 3 
0.8144933 3 
0.8180958 3 
0.7862212 3 
0.8342704 3 

数据组2:

0.8551 2001 
0.8626 2001 
0.716 2001 
0.8455 2001 
0.847 2001 
0.794 2001 
0.8144 2001 
0.7992 2001 
0.7794 2001 
0.8121 2001 
0.8364 2001 
0.8778 2001 
0.8698 2001 
0.872 2001 
0.8775 2001 
0.8226 2001 
0.8226 2001 
0.8226 2001 
0.8049 2001 
0.783 2001 
0.8611 2002 
0.8738 2002 
0.7886 2002 
0.8762 2002 
0.8797 2002 
0.844 2002 
0.7166 2002 
0.841 2002 
0.8069 2002 
0.8393 2002 
0.8323 2002 
0.8771 2002 
0.8748 2002 
0.8748 2002 
0.8704 2002 
0.836 2002 
0.8403 2002 
0.8162 2002 
0.8429 2002 
0.828 2002 

主要问题: 如何将多个图表放在具有相同y轴范围但变化x轴的同一图表中?

进一步解释: 第一列的两个数据集区域包含CELL值,而对于“数据集1”第二列是“类别”,而对于“数据集2”第二列是“年”。我想要Y轴上的“单元格”,而“X轴”中的“类别”和“年份”。非常感谢

我希望将类别排列起来和/或堆放在箱子/胡须中。

+1

你究竟想用这个做什么?在相同的空间中绘制两组不同的数据是很容易的,但你希望它们排列或区分?你想让“类别”与“2000年”一致吗?没有更多的解释,这真的感觉像是应该是一个分类比较(即盒子和胡须图),或者是两个独立的图,以便可读。 – Dinre 2013-03-07 18:19:56

+0

@Dinre我编辑了我的问题。谢谢 – arjm 2013-03-07 18:31:37

回答

0

这里是另一个解决方案,它可能会有所帮助。这

data1 <- read.table("data1.txt") 
data2 <- read.table("data2.txt") 
names(data1) <- c("cell","category") 
names(data2) <- c("cell","year") 
library(reshape2) 
library(ggplot2) 
meltdata1 <- melt(data1, id=c("cell")) 
head(meltdata1) 

meltdata2 <- melt(data2, id=c("cell")) 
comb <- rbind(meltdata1,meltdata2) 
head(comb) 

ggplot(comb, aes(x=factor(value), y=cell))+geom_boxplot()+facet_wrap(~variable, scales="free_x")+xlab(" Category/Year") 

输出如下:

enter image description here

希望它能帮助。

0

这里的东西:

datasetcomb<-rbind(dataset1,dataset2) #combine datasets 

#V1 is cell, V2 is another variable 

boxplot(V1~factor(V2),data=datasetcomb,at=c(1,4,7,2,5),ylab="Cell", 
    xlab="Category/Year",xaxt="n",col=c(3,3,3,2,2)) 
axis(side=1,at=c(1,4,7,2,5),labels=c(1,2,3,2000,2001)) 
相关问题