R – Plot Line Thickness
To set plot line width/thickness in R, call plot() function and along with the data to be plot, pass required thickness/line-width value for the “lwd” parameter.
In this tutorial, we will learn how to set plot line width, with example programs.
The syntax to draw a plot with twice the default thickness using plot() function is
plot(x, y, lwd=2.0)
In the following program, we will take two vectors in
y, and plot Y vs X, using plot() function with the line width set to 2.0.
x <- seq(0, 10, 0.5) y <- sin(x) plot(x, y, lwd=2.0)
Now, let us increase the line width to 5.0 and observe the output plot.
x <- seq(0, 10, 0.5) y <- sin(x) plot(x, y, lwd=5.0)
In the following program, we will draw a line plot and set the plot’s line width to 5.0.
x <- seq(0, 10, 0.5) y <- sin(x) plot(x, y, type="l", lwd=5.0)
In this R Tutorial, we learned how to set plot line width/thickness via plot() function, with the help of example program.