Drawing histogram and bar graph for Python data visualization

Time:2021-12-30

1、 Purpose of the experiment:

1. Master the use of histogram and bar graph drawing functions in Python

2. Use the above drawing functions to realize data visualization

2、 Experiment content:

1. Practice the usage of histogram and bar graph drawing functions in Python, and master the concepts of relevant parameters

2. Process the experimental data according to the drawing function requirements in step 1

3. Draw histogram and bar chart according to the experimental data obtained in step 2

4. Practice how to make the picture present different effects by adjusting parameters, such as color, legend position, background grid, coordinate axis scale and mark, etc

3、 Experimental process (with screenshot of results):

1. Practice the usage of histogram and bar graph drawing functions in Python, and master the concepts of relevant parameters

(1) Practice using the bar graph function

import matplotlib. pyplot as plt

Drawing histogram and bar graph for Python data visualization

2. Process the experimental data according to the drawing function requirements in step 1

(1) The experimental data are as follows

Types of drinks: "carbonated drinks", "green tea", "mineral water", "fruit juice", "others"

3. Draw histogram and bar chart according to the experimental data obtained in step 2

(1) Draw bar chart

import matplotlib. pyplot as plt

Drawing histogram and bar graph for Python data visualization

4. Practice how to make the picture present different effects by adjusting parameters, such as color, legend position, background grid, coordinate axis scale and mark, etc

(1) If you want to draw two bar charts to display the survey of boys and girls, you can use bar or barh function twice, and adjust the bar chart position coordinates and corresponding scales of bar or barh function, so that the two groups of bar charts can be displayed side by side

import matplotlib. pyplot as plt

Drawing histogram and bar graph for Python data visualization

This is the end of this article on drawing histogram and bar graph for Python data visualization. For more information about Python drawing histogram and bar graph, please search for previous articles on developeppaper or continue to browse the following articles. I hope you will support developeppaper in the future!