This article introduces how to use Python to draw different charts based on Excel table data. It is very detailed. Friends who have the same needs can refer to it.
This article introduces how to use Python to summarize commonly used Charts, compared with the click-and-click operation of Excel, drawing charts with python seems more cumbersome, especially in the processing of original data. However, the two have roughly the same idea in the process of drawing charts. Most of the work that can be done in Excel can also be done by python. In order to explain more clearly the process of drawing charts using python, we annotate the code of the summary chart to explain the specific function of each line of code. At the end of the article, a corresponding table of custom fonts and chart colors is given.
Preparation
1 2 3 4 5 |
|
Line chart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
Bar chart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
##Bar chart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
|
##Histogram
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Custom fonts and colors
used in charts Font, you can use the following font name to replace the content after family= to change the font displayed in the chart.
For the colors in the chart, you can use the color name directly, or you can use the abbreviation to set the color used in the chart. This article does not use the default color, but uses Custom colors.
The color number of custom colors. The Hex color number is used in this article. The corresponding relationship between Hex and RGB, as well as the corresponding colors, are given below. You can use the Hex color numbers below to replace the colors of the charts in this article.
Related recommendations:
How to use python to draw a line chart
Use python to draw graphics Detailed explanation of examples
The above is the detailed content of Draw commonly used charts using python. For more information, please follow other related articles on the PHP Chinese website!