Current location - Education and Training Encyclopedia - Graduation thesis - Figure 8. Cake drawn by sci article.
Figure 8. Cake 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)?

FigDraw? 7.? SCI? The article draws a line chart? (line chart)

Pie chart of fig. 8. SCI article drawing?

Pie charts are widely used in various fields to show the proportion of different classifications and compare various classifications through radians. Pie charts divide a cake into multiple slices according to the proportion of classification. The whole pie chart represents the total amount of data, and each slice (arc) represents the proportion of classification in the total amount. The sum of all slices (arcs) is equal to 100%. Pie charts can help users quickly understand the proportional distribution of data. Its main disadvantages are:

(1) Pie charts are not suitable for multi-category data. In principle, a pie chart cannot have more than 9 categories. Because with the increase of classification, each slice will become smaller, and the final size difference is not obvious, and each slice looks similar in size, which is meaningless for data comparison;

(2) Compared with other charts with the same function (such as percentage stacked column chart and circle chart), pie chart needs to occupy more canvas space, so it is not suitable for scenes with large data;

(3) It is difficult to make numerical comparison between multiple pie charts, and it can be replaced by a percentage stacked column chart or a percentage stacked bar chart;

(4) Pie charts are not suitable for the scale visualization of multivariate continuous data, so percentage accumulation area charts should be used to display data, such as multivariate time series data.

How to draw a pie chart with ggplot2? Actually, ggplot2 does not have the function of drawing pie chart similar to geom_pie (), but ggplot2 has an idea of drawing pie chart through polar coordinate transformation. Here, we will teach you to draw a beautiful pie chart step by step. So much for the pie chart. If you want to draw a 3D pie chart, ggplot2 is not a good choice, because it can't realize the 3D function at present. So here are three kinds of painting methods, each with its own characteristics. Just choose the one that suits you when you use it!

Install the software package first, as follows:

We constructed a set of data, fruit sales, as follows:

Before drawing a pie chart, you need to draw a stacked bar chart. After the polar coordinate transformation, you can draw a pie chart.

In ggplot2, the pie chart is obtained by polar coordinate transformation, as follows:

We can also write the label on the pie chart, so remove the lent one first, as follows:

When adding text, we need to pay attention to adjust the order of data and text, as follows:

After adjusting the order, draw the pie chart again, as shown below:

We said that it is too much trouble to use ggplot2, and there is a function that can directly draw pie charts. Why is it far more than near? Go directly to the function pie () and it's done!

I feel that the default color is much fresher than the color scheme of ggplot2, and it feels like summer, don't you think?

Grey system, some periodicals are especially suitable for this color system, simple and atmospheric!

In addition to flat pie charts, plotrix software package also provides 3D pie charts. This function is very similar to the three-dimensional pie chart made by excel, and it is also very easy to use.

Having summed up so much, do you know how to make the pie chart clearer? The possible graphics in the article have been included in the details. Study it carefully, and you will be suddenly enlightened! !