我有一个整数向量,例如:2,8,11,19
。如何绘制R中的一维图?
我想绘制一条线的长度,例如20,然后绘制了存在于列表(在一些固定的高度)的每个值点,所以我得到的是这样的:
-+-----+--+-------+-
我有一个整数向量,例如:2,8,11,19
。如何绘制R中的一维图?
我想绘制一条线的长度,例如20,然后绘制了存在于列表(在一些固定的高度)的每个值点,所以我得到的是这样的:
-+-----+--+-------+-
布兰登贝特尔森是真的很近...
x <- c(2,8,11,19)
x <- data.frame(x,1) ## 1 is your "height"
plot(x, type = 'o', pch = '|', ylab = '')
但我写这主要是为了提,你也可能在基础图形看带状图()和rug()来查看一维数据的方法。
library(lattice)
x <- c(2, 8, 11, 19)
stripplot(x)
可以天秤调整自己的喜好。看到?stripplot
+1感谢您的快速回复! – 2010-09-28 22:36:54
随着基本图形:
x <- c(2,8,11,19)
x <- data.frame(x,1) ## 1 is your "height"
plot(x, type="b")
+1感谢您的快速回复! – 2010-09-28 22:37:04
这可能对绘制一维有序数据的人有帮助。
x<-c(-1.5,2,2.5,-2,.05)
## Make y-value=0
x<-cbind(x,0)
## Plotting without box or axis with dot, representing data points
plot(x,bty='n',xaxt='n',yaxt='n',ylab='',xlab='',pch=21,cex=2)
## Placing axis at y-value in order to pass through points with sequence wider than range
axis(side=1,seq(-4,4,1),pos=0) ## Using y-value as position
## Placing x-values & x-axis label onto plot
text(x,labels=x[,1],pos=3,offset=1,font=2)
text(y=0,x=0,labels='One-Dimensional Plot',pos=1,offset=3,font=2)
贝尔“森”! :P – 2010-09-26 20:28:06
oops ...现在修好了 – John 2010-09-27 20:07:03