Duplicating Discrete Axis in ggplot2

后端 未结 1 1381
难免孤独
难免孤独 2021-01-21 13:15

The development version of ggplot2 (2.1.0.9001) provides a nice shorthand for creating a secondary axis that is a duplication of the primary axis if the original axis i

1条回答
  •  滥情空心
    2021-01-21 13:18

    The switch_axis_position is now deprecated, and in fact is gone. Issues with ggdraw since ggplot2 update

    Outdated material: The cowplot library has used to have that that facility:

    library(cowplot)
    gpv <- ggplot(mpg, aes(displ, factor(cyl))) + 
       geom_point()
    ggdraw( switch_axis_position( gpv, axis="y", keep="y"))
    

    Don't forget that you need to print grid-based graphics when sending to a file:

    png()
      print(ggdraw(switch_axis_position(gpv, axis="y", keep="y")) )
    dev.off()
    #quartz 
    #     2 
    

    0 讨论(0)
提交回复
热议问题