Home > Software engineering >  Draw label as a rectangle with edges rather than with rounded corners
Draw label as a rectangle with edges rather than with rounded corners

Time:12-20

Using geom_label() in ggplot2, is it possible to make the rectangle perfectly square rather than with rounded corners?

data(iris)

ggplot(iris, aes(Sepal.Width, Sepal.Length))   geom_point()   
geom_label(x=4, y=7, label = "Test label")

I want to square up the rounded rectangle around Test label.

Thanks.

CodePudding user response:

Yes you can set the label.r parameter to 0.

library(ggplot2)

ggplot(iris, aes(Sepal.Width, Sepal.Length))   geom_point()  
  geom_label(x=4, y=7, label = "Test label",
             label.r = unit(0, "pt"))

Created on 2021-12-18 by the reprex package (v2.0.1)

  • Related