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

Line chart

Line charts are most often used to indicate change, particularly over time. This time, we will use the longley dataset, featuring economic variables from between 1947 and 1962, as shown in the following code:

> plot(x = 1947 : 1962, y = longley$GNP, type = "l",
  xlab = "Year", main = "Base graphics")

The x axis is given very simply by the 1947 : 1962 phrase, which enumerates all the numbers between 1947 and 1962, and the type = "l" argument specifies the plotting of the lines, as opposed to points or both.

The ggplot call looks a lot like the bar chart, except with an x and y dimension in the aesthetics this time. The command looks as follows:

> ggplot(longley, aes(x = 1947 : 1962, y = GNP)) + geom_line() +
      xlab("Year") + ggtitle("ggplot2")
主站蜘蛛池模板: 二连浩特市| 新昌县| 永德县| 抚州市| 巴中市| 象州县| 渝北区| 额敏县| 莲花县| 繁昌县| 安溪县| 海门市| 恭城| 三台县| 常州市| 房产| 奉新县| 和硕县| 肥西县| 绿春县| 枞阳县| 福建省| 拉孜县| 繁峙县| 招远市| 宁陕县| 长春市| 乐至县| 独山县| 高台县| 屏南县| 雷波县| 利川市| 瑞昌市| 微山县| 永兴县| 遵义市| 华宁县| 惠州市| 米林县| 革吉县|