How can you create a box around an axis tick label in ggplot2?

前端 未结 2 1095
梦毁少年i
梦毁少年i 2021-02-05 09:23

For several reasons, I am trying to duplicate the grotesque plot shown below. It violates many precepts of good data visualization so for training purposes my goal is to use

2条回答
  •  余生分开走
    2021-02-05 10:08

    I think your best bet is to create viewports at the location of the tick labels, and draw a black rectangle and white text there. For example:

    vp1 <- viewport(x = 0.225, y = 0.55, width = 0.45, height = 0.07)
    grid.rect(gp = gpar(fill="black"), vp = vp1)
    grid.text("Lack of anti-bribery corruption training or awareness within the business", gp=gpar(col="white", cex = 0.6), vp = vp1)
    

    Will give you the graph below:enter image description here

提交回复
热议问题