官术网_书友最值得收藏!

Line Charts

A line chart or line graph is a type of chart that displays information as a series of data points called markers connected by straight line segments.

ggplot uses an elegant geom() method, which helps in quickly switching between two visual objects. In the previous example, we saw geom_point() for the scatterplot. In line charts, the observations are connected by a line in the order of the variable on the x-axis. The shaded area surrounding the line represents the 95% confidence interval, that is, there is 95% confidence that the actual regression line lies within the shaded area. We will discuss more on this idea in Chapter 4, Regression.

In the following plot, we show the line chart of age and bank balance for single, married, and divorced individuals. It is not clear whether there is some trend, but one can see the pattern among the three categories:

ggplot(data = df_bank_detail) +

geom_smooth(mapping = aes(x = age, y = balance, linetype = marital))

## 'geom_smooth()' using method = 'gam'

Figure 1.10: Line graph of age and balance

主站蜘蛛池模板: 河南省| 集安市| 东明县| 枞阳县| 阜康市| 滨州市| 罗江县| 德令哈市| 郯城县| 清镇市| 彰化县| 尤溪县| 宁陵县| 栾川县| 河池市| 镇远县| 荥经县| 防城港市| 遂平县| 封丘县| 新野县| 赣榆县| 四子王旗| 额济纳旗| 合水县| 长宁县| 新安县| 五寨县| 昌图县| 科技| 嵩明县| 云和县| 靖远县| 桓台县| 杂多县| 通化县| 新兴县| 安图县| 高雄县| 吉安市| 海南省|