+5 votes
in Programming Languages by (71.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 (349k 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:

library(ggplot2)
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))
p

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

...