- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create horizontal lines with two different colors after a threshold in R?
To create two horizontal lines with different color after a threshold in R, we can follow the below steps −
- First of all, create a plot in base R.
- Then, add a line to the plot using abline function.
- After that, use segments function to partially change the color of the line.
Create the plot
Using plot function to create a plot in base R −
Add a line to the plot
Using abline function to add a line to the plot −
Partially color the line
Using segments function to color the with yellow color starting from 0 to 3 −
plot(1:5,1:5,xlim=c(0,5)) abline(h=3) segments(x0=0,y0=3,x1=2,y1=3,col="yellow")
- How to create a horizontal line in ggplot2 graph with different color in R?
- How to create density plot for categories filled with different colors in R?
- How to create boxplot with horizontal lines on the minimum and maximum in R?
- How to display legend in base R with different colors?
- How to create a scatterplot with colors as group in R?
- How to create a circle with vertical lines in R?
- How to create horizontal lines for each bar in a bar plot of base R?
- How to fill histogram bars using ggplot2 in R with different colors?
- How to create horizontal histogram in R?
- How to create two vertical lines on a plot with shaded area in-between using R?
- How to create a horizontal boxplot in base R?
- How to create a plot using rgb colors in R?
- How to display horizontal grid lines in a JTable with Java?
- How to delete lines after creating a line chart with points in base R?
- How to create two lines using ggplot2 based on a categorical column in R?