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

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

主站蜘蛛池模板: 铜陵市| 瑞丽市| 五河县| 寻乌县| 阿克陶县| 潜山县| 南充市| 无棣县| 建瓯市| 灯塔市| 阜新市| 东乡族自治县| 章丘市| 磴口县| 斗六市| 历史| 潞城市| 盈江县| 吐鲁番市| 理塘县| 平山县| 临湘市| 游戏| 博兴县| 盐源县| 沁水县| 颍上县| 蒲江县| 五指山市| 清苑县| 昌吉市| 安徽省| 安龙县| 正安县| 彝良县| 托里县| 宁城县| 长治市| 平安县| 揭东县| 保亭|