2013-12-08 23 views
3

我收到一個錯誤,似乎通過在同一圖上使用annotation_logticks()coord_flip()進行組合。例如:annotation_logticks()和coord_flip()似乎不兼容

ggplot(mtcars, aes(x=mpg, y=disp)) + 
    geom_line() + 
    annotation_logticks(sides="l") + 
    coord_flip() 

給出了錯誤Error in unit(yticks$y, "native") : 'x' and 'units' must have length > 0traceback()給出了我不完全理解的結果,但似乎與分配單元有關。

另一方面,annotation_logticks()coord_flip()單獨不會導致任何問題。

ggplot(mtcars, aes(x=mpg, y=disp)) + 
    geom_line() + 
    annotation_logticks(sides="l") #+ 
    #coord_flip() 

工作正常,一樣

ggplot(mtcars, aes(x=mpg, y=disp)) + 
    geom_line() + 
    #annotation_logticks(sides="l") #+ 
    coord_flip() 

我可以切換xy映射避免coord_flip(),但這並不是理想的(我不得不重寫舊地塊,如果我想補充annotation_logticks()爲實例)。

+0

這是一個錯誤。你應該聯繫維護者。 – agstudy

+0

問題已在https://github.com/hadley/ggplot2/issues/881 –

+1

問題修復。我發送了一個拉請求。你可以使用我的github版本作爲解決方法。 – agstudy

回答

-1

我在同一problem-

ggplot(aq,aes(x=site,y=nox))+geom_boxplot(outlier.shape = NA, color="blue")+ ylab("Concentration (ppm)")+xlab("Site") +theme_bw()+scale_y_log10()+coord_flip()+stat_summary(fun.y=mean, geom="point", size=1.5)+annotation_logticks(sides="l") 

Error: 'x' and 'units' must have length > 0 In addition: There were 13 warnings (use warnings() to see them)

annotation_logticks()coord_flip()命令現在合作。