我收到一个错误,似乎在同一情节上使用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()
例如,如果要添加,则必须重写旧图)。