Used in plot() function.

Instead of points it shows a line.

```
# Create sample data
x <- 1:10
y <- x^2
# Create a line plot
plot(x, y, type = "l", col = "blue", lty = 2, lwd = 2, main = "Line Plot", xlab = "X-axis", ylab = "Y-axis")
```

**type = "l"**specifies a line plot.**col = "blue"**sets the color of the line to blue.**lty = 2**sets the line type to dashed (you can use different values for various line types).**lwd = 2**sets the line width.

**lty = 1**- Solid line (default).**lty = 2**- Dashed line.**lty = 3**- Dotted line.**lty = 4**- Dot-dash line.**lty = 5**- Long-dash line.**lty = 6**- Two dash-dot line.**lty = 7**- Dash-dot-dot line.

```
# Create sample data
x <- 1:10
y <- x^2
# Create a plot with different line types
plot(x, y, type = "n", main = "Line Types", xlab = "X-axis", ylab = "Y-axis")
lines(x, y, col = "blue", lty = 1, lwd = 2) # Solid line
lines(x, y + 10, col = "green", lty = 2, lwd = 2) # Dashed line
lines(x, y + 20, col = "red", lty = 3, lwd = 2) # Dotted line
lines(x, y + 30, col = "purple", lty = 4, lwd = 2) # Dot-dash line
lines(x, y + 40, col = "orange", lty = 5, lwd = 2) # Long-dash line
lines(x, y + 50, col = "brown", lty = 6, lwd = 2) # Two dash-dot line
lines(x, y + 60, col = "pink", lty = 7, lwd = 2) # Dash-dot-dot line
```

lines() are used to show a line connecting all the points.

This function is mainly used when we dont use type="l" i plot() function.

So that we can show point and connecting lines.

This function is mainly used when we dont use type="l" i plot() function.

So that we can show point and connecting lines.

```
# Create another set of data
x2 <- 1:10
y2 <- 3 * x2 - 1 + rnorm(10)
# Create a new scatter plot
plot(x2, y2, main = "Scatter Plot with Another Line", xlab = "X-axis", ylab = "Y-axis", pch = 16, col = "green")
# Add a line to the existing plot using lines()
lines(x2, y2, col = "orange", lty = 2)
```

We can use albine() function to show an line for the points.

Mainly used in scatterplot.

Mainly used in scatterplot.

Type = "b" plot creates a plot with both points and lines.

The plot will have a data points which will be connected by lines.

**Syntax** plot(x, y, type = "b")

The plot will have a data points which will be connected by lines.

```
# Create sample data
x <- 1:10
y <- x^2
# Create a plot with points and lines
plot(x, y, type = "b", col = "blue", pch = 16, lty = 2, lwd = 2, main = "Points and Lines", xlab = "X-axis", ylab = "Y-axis")
```

R Line

R Line

Types of Line Styles(lyt)

The Concepts and codes you leart practice in Compilers till you are confident of doing on your own. A Various methods of examples, concepts, codes availble in our websites. Don't know where to start Down some code examples are given for this page topic use the code and compiler.

Example 1
Example 2
Example 3
Example 4
Example 5

FEEDBACK