ggplot flip and transform coordinate

后端 未结 1 551
孤城傲影
孤城傲影 2021-01-28 05:02

I want to transform the coordinate (not the scale/values) so that the y variable (flipped to x) is better spaced. I thought it would be coord_trans(y=\"log10\") or

相关标签:
1条回答
  • 2021-01-28 05:16

    OK so now that I understand your question, here's the answer in hopes it will help others.

    First, the coord_* functions cannot be stacked - they override each other. So tthe way you are using it, coord_flip(...) overrides coord_trans(...) and you don't see any transformations.

    To get log10 spacing with tick labels based on the linear spacing, with flipped coordinates, you can use the breaks=... argument to scale_*, as in:

    ggplot(dat) +
      geom_point(aes(y=median, x=name)) +
      scale_y_log10(breaks=1000*(1:3)) +   # note use of breaks=...
      coord_flip() +
      theme_bw() +
      theme(
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.border = element_blank(),
        axis.line = element_line(color = 'black'),
        panel.background = element_blank(),
        axis.title.y = element_blank())
    

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