注解_logticks()和coord_flip()似乎不兼容 [英] annotation_logticks() and coord_flip() seem incompatible

查看:71
本文介绍了注解_logticks()和coord_flip()似乎不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在同一图上使用annotation_logticks()coord_flip()似乎合并了一个错误.例如:

I get an error that seems to be combined by using annotation_logticks() and coord_flip() on the same plot. For instance:

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()给出的结果我不太了解,但似乎与分配单位有关.

gives the error Error in unit(yticks$y, "native") : 'x' and 'units' must have length > 0. traceback() gives results that I don't totally understand, but which seem to have something to do with assigning units.

另一方面,单独annotation_logticks()coord_flip() 不会造成任何问题.

On the other hand, annotation_logticks() or coord_flip() alone doesn't cause any problem.

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(),则必须重写旧图).

I could switch the x and y mappings to avoid coord_flip(), but this is not ideal (I have to rewrite old plots if I want to add annotation_logticks() for instance).

推荐答案

我遇到了同样的问题-

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")

错误:"x"和"units"的长度必须大于0,另外:有13个 警告(使用warnings()查看警告)

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

annotation_logticks()coord_flip()命令现在可以一起使用.

annotation_logticks() and coord_flip() commands are now working together.

这篇关于注解_logticks()和coord_flip()似乎不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆