Current location - Education and Training Encyclopedia - Graduation thesis - Figure 7. The line chart drawn by sci article.
Figure 7. The line chart drawn by sci article.
? Click attention, huanfeng gene

At present, the catalogue of tutorials sorted out is as follows:

FigDraw? 1.? SCI? The soul of the article? What? Simple and generous chart color matching

FigDraw? 2.? SCI? Is it necessary to draw an article? r? Language foundation?

FigDraw? 3.? SCI? Is it necessary to draw an article? r? data conversion

FigDraw? 4.? SCI? The article draws a scatter diagram? (scatter plot)

FigDraw? 5.? SCI? The article draws a histogram? (histogram)

FigDraw? 6.? SCI? The block diagram drawn by the article? (box chart)?

Figure 7. Line chart of sci paper map.

Line chart is also one of the widely used statistical charts, which can reflect the trend of a certain phenomenon. Usually, the abscissa of a line chart is a time variable and the ordinate is a general numerical variable. Of course, a line chart also allows the abscissa to be a discrete numerical value or a numerical value. Let's explain how to draw a line chart.

Geom_line () draws a line chart with few parameters. Basically, five parameters are used to adjust line thickness, color, grouping, line style, grouping and so on. Each parameter is detailed as follows:

Let's draw a line chart about time series.

This data set comes from the time series data of American economy on the Internet. Economics is "wide" and economics_long is "long". A 574-line and 6-variable data framework: the personal consumption expenditure of pce in a month is collected. In billions of dollars, the property of ype (linear type) is sufficient. For more information, see the following example.

Different line colors.

Different linetypes

Customize colors, lines, shapes of points, fill colors of points, etc. , as follows:

Using color to represent grouping variables is the most common form, and the default color scheme only needs to be called. The DIY color matching function that can be used for line charts is scale_colour_manual (). The parameters include: palette: palette design, which contains many colors for values = to call.

Value: color value, which can be a column.

Labels: Grouping labels, each color represents a group.

Name: the legendary name.

Breaks: To set up a group, you need as many elements as labels.

Constraint: It affects the elements displayed on the graph. If there are four elements in limits, but there are actually only two grouping variables, then two NA values will appear.

Where colour sets the color of the border of the regional map; Size sets the thickness of the border line; Alpha Sets the transparency of area charts and border lines.

It should also be noted that when drawing multiple line charts, if the abscissa is a factor, the parameter' group = grouping variable' must be added, otherwise the error will be reported or the chart will be drawn incorrectly.

The line charts drawn above all adopt the default format, and no custom format is given in terms of color, shape, size or transparency. In fact, the ggplot2 package also allows users to set these properties according to their own ideas.

User-defined parameter descriptions can be customized, and they can be changed as needed. The premise is that the content of aes () attribute corresponds to the customized content.

Drawing the superimposed area map can be easily realized by using the geom_area () function and mapping a discrete variable to fill it, so try it a little first.

Modify the fill color fill and top line color. If you need to add a straight line at the top of each regional map, you can do it in the following two ways:

Where colour sets the color of the border of the regional map; Size sets the thickness of the border line; Alpha Sets the transparency of area charts and border lines.

Add a line at the top of the stacked area diagram.

In the area chart, you can also draw the percentage cumulative area chart conveniently and quickly, as shown in the following figure:

Add a line at the top of the percentage stacked area chart.

We combine the stacked area map as follows: