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

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")
主站蜘蛛池模板: 余姚市| 随州市| 屏南县| 德格县| 泸西县| 毕节市| 峨眉山市| 双流县| 博罗县| 淮南市| 广灵县| 凤冈县| 安康市| 阳山县| 夏津县| 安吉县| 海原县| 新安县| 耿马| 会同县| 庄河市| 松潘县| 喀喇| 夏邑县| 玉田县| 霍山县| 墨竹工卡县| 临沧市| 红桥区| 察隅县| 翼城县| 柳河县| 安溪县| 祁东县| 南川市| 承德市| 英山县| 当阳市| 南雄市| 越西县| 罗田县|