How to make geom_text plot within the canvas's bounds

前端 未结 4 1198
无人及你
无人及你 2020-11-29 03:55

Using geom_text to label outlying points of scatter plot. By definition, these points tend to be close to the canvas edges: there is usually at least one word that overlaps

4条回答
  •  一向
    一向 (楼主)
    2020-11-29 04:18

    ggplot 2.0.0 introduced new options for hjust and vjust for geom_text() that may help with clipping, especially "inward". We could do:

    ggplot(data=df, aes(x=n.wheels, y=utility, label=word))  + 
      geom_text(vjust="inward",hjust="inward")
    

提交回复
热议问题