Cải thiện bài viết
Lưu bài viết
Cải thiện bài viết
Lưu bài viết
Đọc is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.
Bàn luận
Matplotlib là một thư viện trong Python và nó là số mở rộng toán học cho thư viện numpy. Pyplot là giao diện dựa trên trạng thái cho mô-đun matplotlib cung cấp giao diện giống MATLAB.hist[] function in pyplot module of matplotlib library is used to plot a histogram.
hàm matplotlib.pyplot.hist [] matplotlib.pyplot.hist[x, bins=None, range=None, density=False, weights=None, cumulative=False, bottom=None, histtype=’bar’, align=’mid’, orientation=’vertical’, rwidth=None, log=False, color=None, label=None, stacked=False, \*, data=None, \*\*kwargs]
Hàm Hist [] trong mô -đun pyplot của thư viện matplotlib được sử dụng để vẽ biểu đồ biểu đồ. This method accept the following parameters that are described below:
- Cú pháp: matplotlib.pyplot. ', rwidth = none, log = false, color = none, label = none, stacked = false, \*, data = none, \*\*kwargs]This parameter are the sequence of data.
- Tham số: Phương pháp này chấp nhận các tham số sau được mô tả dưới đây:This parameter is an optional parameter and it contains the integer or sequence or string.
- X: Tham số này là chuỗi dữ liệu.This parameter is an optional parameter and it the lower and upper range of the bins.
- BIN: Tham số này là một tham số tùy chọn và nó chứa số nguyên hoặc chuỗi hoặc chuỗi.This parameter is an optional parameter and it contains the boolean values.
- Phạm vi: Tham số này là một tham số tùy chọn và nó là phạm vi dưới và trên của các thùng.This parameter is an optional parameter and it is an array of weights, of the same shape as x.
- Mật độ: Tham số này là một tham số tùy chọn và nó chứa các giá trị boolean.This parameter is the location of the bottom baseline of each bin.
- Trọng lượng: Tham số này là một tham số tùy chọn và nó là một mảng các trọng số, có hình dạng giống như x.This parameter is an optional parameter and it is used to draw type of histogram. {‘bar’, ‘barstacked’, ‘step’, ‘stepfilled’}
- Dưới cùng: Tham số này là vị trí của đường cơ sở dưới cùng của mỗi thùng.This parameter is an optional parameter and it controls how the histogram is plotted. {‘left’, ‘mid’, ‘right’}
- HistType: Tham số này là một tham số tùy chọn và nó được sử dụng để vẽ loại biểu đồ. {‘Bar,‘ BarstackedThis parameter is an optional parameter and it is a relative width of the bars as a fraction of the bin width
- Căn chỉnh: Tham số này là một tham số tùy chọn và nó kiểm soát cách biểu đồ biểu đồ. {’TráiThis parameter is an optional parameter and it is used to set histogram axis to a log scale
- RWIDTH: Tham số này là một tham số tùy chọn và nó là chiều rộng tương đối của các thanh dưới dạng một phần của chiều rộng binThis parameter is an optional parameter and it is a color spec or sequence of color specs, one per dataset.
- log: tham số này là một tham số tùy chọn và nó được sử dụng để đặt trục biểu đồ thành thang đo nhật kýThis parameter is an optional parameter and it is a string, or sequence of strings to match multiple datasets.
- Màu sắc: Tham số này là một tham số tùy chọn và nó là một thông số màu hoặc chuỗi thông số kỹ thuật màu, một tập dữ liệu.This parameter is an optional parameter and it contains the boolean values.It uses the density keyword argument instead.
Nhãn: Tham số này là một tham số tùy chọn và nó là một chuỗi hoặc chuỗi chuỗi để khớp với nhiều bộ dữ liệu. This returns the following:
- Normed: Tham số này là một tham số tùy chọn và nó chứa các giá trị boolean. Nó sử dụng đối số từ khóa mật độ thay thế.This returns the values of the histogram bins.
- Trả về: Điều này trả về như sau:This returns the edges of the bins.
- N: Điều này trả về các giá trị của các thùng biểu đồ.This returns the list of individual patches used to create the histogram.
Bins: Điều này trả về các cạnh của các thùng.
Các bản vá: Điều này trả về danh sách các bản vá riêng lẻ được sử dụng để tạo biểu đồ.
Dưới đây các ví dụ minh họa hàm matplotlib.pyplot.hist [] trong matplotlib.pyplot:
Ví dụ 1:
import
matplotlib
np.random.seed[
10
*
*
matplotlib
0matplotlib
1
import
numpy as np
import
matplotlib.pyplot as plt
matplotlib
2matplotlib
3 ________ 14 & nbsp;
matplotlib
5matplotlib
3 matplotlib
7
matplotlib
8matplotlib
3 matplotlib
2import
1 matplotlib
5*
import
7matplotlib
3 import
9
numpy as np
3numpy as np
9matplotlib
3import
1import
2
numpy as np
0matplotlib
3 numpy as np
2
numpy as np
3numpy as np
4matplotlib
3 numpy as np
6numpy as np
7
numpy as np
3import
4matplotlib
3 import
6matplotlib
1
10
710
810
9matplotlib
3*
1matplotlib
1
*
3*
4matplotlib
1
*
6*
7matplotlib
1
*
9*
0import
2
*
2*
3matplotlib
3*
5matplotlib
1
*
7
Output:
import
8matplotlib
3 matplotlib.pyplot as plt
0numpy as np
6 matplotlib.pyplot as plt
2 matplotlib.pyplot as plt
3matplotlib.pyplot as plt
4 *
Dưới đây các ví dụ minh họa hàm matplotlib.pyplot.hist [] trong matplotlib.pyplot:
Ví dụ 1:
import
matplotlib
np.random.seed[
10
*
*
matplotlib
0matplotlib
1
import
numpy as np
import
matplotlib.pyplot as plt
matplotlib
2matplotlib
3 ________ 14 & nbsp;
matplotlib
5matplotlib
3 matplotlib
7
matplotlib
8matplotlib
3 matplotlib
2import
1 matplotlib
5*
import
7matplotlib
3 import
9
numpy as np
0matplotlib
3 numpy as np
2
matplotlib
46matplotlib
3matplotlib
48matplotlib
49matplotlib
5010
matplotlib
52
*
9*
0import
2
*
2*
3matplotlib
3*
5matplotlib
1
*
7
Output: