ggplot2: How to rotate a graph in a specific angle?

前端 未结 1 1573
时光说笑
时光说笑 2021-01-12 19:09

I would like to rotate a ggplot2 graph by a self-specified angle. I found how to rotate the axis text with element_text(angle = 20). I would like to do somethin

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-12 20:11

    Here's a rough idea, calling your plot p:

    library(grid)
    pushViewport(viewport(name = "rotate", angle = 20, clip = "off", width = 0.7, height = 0.7))
    print(p, vp = "rotate")
    

    You'll probably want to tailor the width and height to the angle and aspect ratio you want.

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