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
ĐọcMatplotlib
Bàn luận
Điều kiện tiên quyết: matplotlib
- Trong bài viết này, chúng tôi sẽ tạo ra một sơ đồ phân tán với các thanh lỗi bằng matplotlib. Biểu đồ thanh lỗi là một cách tuyệt vời để thể hiện sự biến đổi trong dữ liệu của bạn. Nó có thể được áp dụng cho các biểu đồ để cung cấp một lớp thông tin chi tiết bổ sung về dữ liệu được trình bày. & NBSP;
- Cách tiếp cận
- Nhập thư viện Python yêu cầu.
- Tạo dữ liệu.
Chuyển các giá trị bắt buộc cho hàm error [] matplotlib.pyplot.errorbar[x, y, yerr=None, xerr=None, fmt=”, ecolor=None, elinewidth=None, capsize=None, barsabove=False, lolims=False, uplims=False, xlolims=False, xuplims=False, errorevery=1, capthick=None, \*, data=None, \*\*kwargs]
Đồ thị lô. This method accept the following parameters that are described below:
- Cú pháp: matplotlib.pyplot.errorbar [x, y, yerr = none, xerr = none, fmt = Hồi, ecolor = none, elinewidth = none, capsize = none SaiThese parameters are the horizontal and vertical coordinates of the data points.
- 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 string value.
- X, Y: Các tham số này là tọa độ ngang và dọc của các điểm dữ liệu.This parameter is also an optional parameter. And it is the length of the error bar caps in points with default value NONE.
FMT: Tham số này là một tham số tùy chọn và nó chứa giá trị chuỗi.
Capsize: Tham số này cũng là một tham số tùy chọn. Và đó là độ dài của thanh thanh lỗi theo điểm với giá trị mặc định Không có. Adding Some error in a ‘y’ value.
Python3
Việc thực hiện khái niệm được thảo luận ở trên được đưa ra dưới đây:
Ví dụ 1: Thêm một số lỗi trong giá trị ‘Y.
import
matplotlib.pyplot as plt
a
5
a
=
[
1
,
____________,
5
,
matplotlib.pyplot as plt
1
=
7=
=
9=
[
1[
2
[
3
Output:
matplotlib.pyplot as plt
3=
[
matplotlib.pyplot as plt
6____________matplotlib.pyplot as plt
8matplotlib.pyplot as plt
9____________a
1,
a
3matplotlib.pyplot as plt
2 Adding Some errors in the ‘x’ value.
Python3
Việc thực hiện khái niệm được thảo luận ở trên được đưa ra dưới đây:
Ví dụ 1: Thêm một số lỗi trong giá trị ‘Y.
import
matplotlib.pyplot as plt
a
5
a
=
[
1
,
____________,
5
,
matplotlib.pyplot as plt
1
,
1=
=
9=
[
1[
2
[
3
Output:
matplotlib.pyplot as plt
3=
[
matplotlib.pyplot as plt
6____________matplotlib.pyplot as plt
8matplotlib.pyplot as plt
9____________a
1,
a
3matplotlib.pyplot as plt
2 Adding error in x & y
Python3
Việc thực hiện khái niệm được thảo luận ở trên được đưa ra dưới đây:
Ví dụ 1: Thêm một số lỗi trong giá trị ‘Y.
import
matplotlib.pyplot as plt
a
5
a
=
[
1
,
____________,
5
,
matplotlib.pyplot as plt
1
matplotlib.pyplot as plt
3=
[
matplotlib.pyplot as plt
6____________matplotlib.pyplot as plt
8matplotlib.pyplot as plt
9____________a
1,
a
3matplotlib.pyplot as plt
2
,
1=
matplotlib.pyplot as plt
38=
matplotlib.pyplot as plt
40=
[
1matplotlib.pyplot as plt
43=
matplotlib.pyplot as plt
45[
2
[
3
Output:
a
6=
[
1
,
____________,
matplotlib.pyplot as plt
9________1
____matplotlib.pyplot as plt
2Adding variable error in x and y.
Python3
Việc thực hiện khái niệm được thảo luận ở trên được đưa ra dưới đây:
Ví dụ 1: Thêm một số lỗi trong giá trị ‘Y.
import
matplotlib.pyplot as plt
a
=
[
1
,
____________,
5
,
matplotlib.pyplot as plt
1
matplotlib.pyplot as plt
85matplotlib.pyplot as plt
79,
matplotlib.pyplot as plt
83matplotlib.pyplot as plt
2
matplotlib.pyplot as plt
3=
[
matplotlib.pyplot as plt
6____________matplotlib.pyplot as plt
8matplotlib.pyplot as plt
9____________a
1,
a
3matplotlib.pyplot as plt
2
matplotlib.pyplot as plt
85matplotlib.pyplot as plt
95,
matplotlib.pyplot as plt
93matplotlib.pyplot as plt
2
a
6=
[
1
,
____________,
matplotlib.pyplot as plt
9________1
____matplotlib.pyplot as plt
2
Ví dụ 2: Thêm một số lỗi trong giá trị ‘X.
a
10
a
11a
12=
a
14
Ví dụ 3: Thêm lỗi trong X & Y
a
11a
20=
a
22a
23
[
3
Output: