- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- 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 join points in a point chart with lines using ggplot2 in R?
Usually, a point chart is created to assess the relationship or movement of two variables together but sometimes these points are scattered in a way that makes confusion. Hence, data analyst or researcher try to visualize this type of graph by joining the points with lines. In ggplot2, this joining can be done by using geom_line() function.
Consider the below data frame −
set.seed(111) x<-rpois(10,5) y<-rpois(10,8) grp<-sample(LETTERS[1:3],10,replace=TRUE) df<-data.frame(x,y,grp) df
x y grp 1 5 8 B 2 6 8 A 3 4 4 B 4 5 4 B 5 4 5 C 6 4 7 A 7 1 5 B 8 5 14 A 9 4 6 C 10 2 9 B
Loading ggplot2 package and creating a point chart between x and y −
Creating point chart between x and y with lines joining the points −
- Related Articles
- How to create a point chart with empty points using ggplot2 in R?
- How to join the points of a point chart if X-axis values are categorical in R using ggplot2?
- How to join points on a scatterplot with smooth lines in R using plot function?
- How to create a point chart for cumulative sums using ggplot2 in R?
- How to change the color of lines for a line chart using ggplot2 in R?
- How to create bar chart using ggplot2 with chart sub-title in R?
- How to display mean for each group in point chart using ggplot2 in R?
- How to delete lines after creating a line chart with points in base R?
- How to create a point chart in R with alternative points having different shape?
- How to create a line chart using ggplot2 with larger width in R?
- How to create a line chart using ggplot2 with a vertical line in R?
- How to create a scatterplot with dark points using ggplot2 in R?
- How to create line chart using ggplot2 in R with 3-sigma limits?
- How to create the bar chart with ggplot2 using color brewer in R?
- How to create a scatterplot in R using ggplot2 with transparency of points?