我收到一個錯誤,似乎通過在同一圖上使用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 > 0
。 traceback()
給出了我不完全理解的結果,但似乎與分配單元有關。
另一方面,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()
我可以切換x
和y
映射避免coord_flip()
,但這並不是理想的(我不得不重寫舊地塊,如果我想補充annotation_logticks()
爲實例)。
這是一個錯誤。你應該聯繫維護者。 – agstudy
問題已在https://github.com/hadley/ggplot2/issues/881 –
問題修復。我發送了一個拉請求。你可以使用我的github版本作爲解決方法。 – agstudy