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

1 Answer

+2 votes
by (281k points)
selected by
Best answer

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

Related questions

+1 vote
1 answer
+3 votes
1 answer
+3 votes
1 answer
+1 vote
1 answer