[英]Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ for Gamma distribution plot
[英]Plot a line graph, error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ
a<- c(2,2)
b<- c(3,4)
plot(a,b) # It works perfectly here
然后我嘗試了:
t<-xy.coords(a,b)
plot(t) # It also works well here
最后,我試過:
plot(t,1)
現在它告訴我:
xy.coords(x,y,xlabel,ylabel,log)出錯:'x'和'y'長度不同
它不起作用,在t內, a和b都是長度為2 ,為什么它顯示x,y長度不同?
plot(t)
在這種情況下是相同的
plot(t[[1]], t[[2]])
正如錯誤消息所示,x和y的長度不同,這是因為您繪制了長度為4的列表1
:
> length(t)
[1] 4
> length(1)
[1] 1
在第二個例子中,你繪制的元素命名列表x
和y
,長度為2的兩個向量,所以plot
繪制這兩個載體。
編輯:
如果你想繪制線條使用
plot(t, type="l")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.