Annotation_logticks () and coord_flip () seem to be incompatible

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

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

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

On the other hand, it only annotation_logticks()or coord_flip()does not cause any problems.

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

works fine, like

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

I could switch the displays xand yto avoid coord_flip(), but this is not ideal (I need to rewrite the old graphs if I want to add annotation_logticks(), for example).

+4
source share
1 answer

-

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 ( (), )

annotation_logticks() coord_flip() .

-1

All Articles