+4 votes
in Programming Languages by (17.7k points)
The default thickness of the line in gglplot is very small. How can I change the thickness of the line?

1 Answer

0 votes
by (35.8k points)

The size argument of geom_line() can be used to set the thickness of the line plot. The default size is 1, you can specify any integer or float value for it.

Here is an example:

xv <- seq(-1,1,1/20)
lw <- 1.5
df <- data.frame(x=xv, y=sin(xv))

p <- ggplot(df, aes(x=x, y=y)) +
  geom_line(size=lw) +
  ggtitle(paste("line thickness:", lw))

The above code will display the following plot:

ggplot line thickness