Trong thế giới ngày nay, rất nhiều dữ liệu đang được tạo ra hàng ngày. Và đôi khi để phân tích dữ liệu này cho một số xu hướng nhất định, các mẫu có thể trở nên khó khăn nếu dữ liệu ở định dạng thô. Để khắc phục trực quan dữ liệu này ra đời. Trực quan hóa dữ liệu cung cấp một biểu diễn hình ảnh tốt, có tổ chức của dữ liệu giúp dễ hiểu, quan sát, phân tích. Trong hướng dẫn này, chúng tôi sẽ thảo luận về cách trực quan hóa dữ liệu bằng Python.
Python cung cấp các thư viện khác nhau đi kèm với các tính năng khác nhau để trực quan hóa dữ liệu. Tất cả các thư viện này đi kèm với các tính năng khác nhau và có thể hỗ trợ các loại đồ thị khác nhau. Trong hướng dẫn này, chúng tôi sẽ thảo luận về bốn thư viện như vậy.
- Matplotlib
- SeaBall
- Bokeh
- Âm mưu
Chúng tôi sẽ thảo luận từng thư viện này từng người một và sẽ vẽ một số đồ thị được sử dụng phổ biến nhất. & NBSP;
Lưu ý: Nếu bạn muốn tìm hiểu thông tin chuyên sâu về các thư viện này, bạn có thể làm theo hướng dẫn đầy đủ của họ.If you want to learn in-depth information about these libraries you can follow their complete tutorial.
Trước khi lặn vào các thư viện này, lúc đầu, chúng tôi sẽ cần một cơ sở dữ liệu để vẽ dữ liệu. Chúng tôi sẽ sử dụng cơ sở dữ liệu mẹo cho hướng dẫn hoàn chỉnh này. Hãy để thảo luận về việc xem một bản tóm tắt về cơ sở dữ liệu này.
Cơ sở dữ liệu được sử dụng
Cơ sở dữ liệu mẹo
Cơ sở dữ liệu Mẹo là hồ sơ về mẹo được cung cấp bởi khách hàng trong một nhà hàng trong hai tháng rưỡi vào đầu những năm 1990. Nó chứa 6 cột như Total_Bill, Tip, Sex, Smoker, ngày, thời gian, kích thước.
Bạn có thể tải xuống cơ sở dữ liệu mẹo từ đây.
Example:
Python3
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pip install seaborn1
pip install seaborn2
pip install seaborn3
Output:
Matplotlib
SeaBall
Bokeh
pip install matplotlib
Âm mưu
- Chúng tôi sẽ thảo luận từng thư viện này từng người một và sẽ vẽ một số đồ thị được sử dụng phổ biến nhất. & NBSP;
- Lưu ý: Nếu bạn muốn tìm hiểu thông tin chuyên sâu về các thư viện này, bạn có thể làm theo hướng dẫn đầy đủ của họ.
Trước khi lặn vào các thư viện này, lúc đầu, chúng tôi sẽ cần một cơ sở dữ liệu để vẽ dữ liệu. Chúng tôi sẽ sử dụng cơ sở dữ liệu mẹo cho hướng dẫn hoàn chỉnh này. Hãy để thảo luận về việc xem một bản tóm tắt về cơ sở dữ liệu này.
Cơ sở dữ liệu được sử dụng
Cơ sở dữ liệu mẹoscatter[] method in the matplotlib library is used to draw a scatter plot.
Example:
Python3
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
data
=
pd.read_csv[
"tips.csv"
____10
pip install bokeh3
pip install bokeh4
pip install bokeh5
pip install bokeh6
pip install bokeh7
pip install bokeh8
pip install bokeh9
pip install seaborn0
pip install plotly1
pip install plotly2
pip install seaborn0
Matplotlib là một thư viện trực quan hóa dữ liệu cấp thấp, dễ sử dụng, được xây dựng trên các mảng numpy. Nó bao gồm các lô khác nhau như biểu đồ phân tán, cốt truyện dòng, biểu đồ, v.v. Matplotlib cung cấp rất nhiều tính linh hoạt. & NBSP;
pip install plotly7
Output:
Để cài đặt loại này lệnh dưới đây trong thiết bị đầu cuối.c and s parameterrespectivelyof the scatter function. We can also show the color bar using the colorbar[] method.
Example:
Python3
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
data
=
pd.read_csv[
"tips.csv"
____10
pip install bokeh3
pip install bokeh4
pip install bokeh5
pip install bokeh6
pandas as pd
1=
pandas as pd
3pandas as pd
4pandas as pd
5pandas as pd
6pandas as pd
7=
pandas as pd
3data
0
pip install bokeh7
pip install bokeh8
pip install bokeh9
pip install seaborn0
Matplotlib là một thư viện trực quan hóa dữ liệu cấp thấp, dễ sử dụng, được xây dựng trên các mảng numpy. Nó bao gồm các lô khác nhau như biểu đồ phân tán, cốt truyện dòng, biểu đồ, v.v. Matplotlib cung cấp rất nhiều tính linh hoạt. & NBSP;
pip install plotly4
pip install plotly5
pip install seaborn0
=
1
pip install plotly7
Output:
Để cài đặt loại này lệnh dưới đây trong thiết bị đầu cuối.
Tham khảo các bài viết dưới đây để có thêm thông tin thiết lập môi trường với matplotlib.plot[] function. Let’s see the below example.
Example:
Python3
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
data
=
pd.read_csv[
"tips.csv"
____10
pd.read_csv[
2
pip install bokeh6
pip install bokeh7
pd.read_csv[
2pandas as pd
4
pip install bokeh7
pip install bokeh8
pip install bokeh9
pip install seaborn0
pip install plotly1
pip install plotly2
pip install seaborn0
pip install plotly4
pip install plotly5
pip install seaborn0
pip install plotly7
Output:
Matplotlib là một thư viện trực quan hóa dữ liệu cấp thấp, dễ sử dụng, được xây dựng trên các mảng numpy. Nó bao gồm các lô khác nhau như biểu đồ phân tán, cốt truyện dòng, biểu đồ, v.v. Matplotlib cung cấp rất nhiều tính linh hoạt. & NBSP;
Để cài đặt loại này lệnh dưới đây trong thiết bị đầu cuối.bar[] method.
Example:
Python3
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
data
=
pd.read_csv[
"tips.csv"
____10
pip install seaborn07
pip install bokeh4
pip install bokeh5
pip install bokeh6
pip install bokeh7
pip install bokeh8
pip install seaborn13
pip install seaborn0
pip install plotly1
pip install plotly2
pip install seaborn0
pip install plotly4
pip install plotly5
pip install seaborn0
pip install plotly7
Output:
Matplotlib là một thư viện trực quan hóa dữ liệu cấp thấp, dễ sử dụng, được xây dựng trên các mảng numpy. Nó bao gồm các lô khác nhau như biểu đồ phân tán, cốt truyện dòng, biểu đồ, v.v. Matplotlib cung cấp rất nhiều tính linh hoạt. & NBSP;
Để cài đặt loại này lệnh dưới đây trong thiết bị đầu cuối.hist[] function is used to compute and create a histogram. In histogram, if we pass categorical data then it will automatically compute the frequency of that data i.e. how often each value occurred.
Example:
Python3
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
data
=
pd.read_csv[
"tips.csv"
____10
pip install seaborn31
data
0pip install bokeh7
pip install bokeh8
pip install seaborn35
pip install seaborn0
pip install plotly7
Output:
Lưu ý: Đối với hướng dẫn hoàn chỉnh Matplotlib, hãy tham khảo hướng dẫn MatplotlibFor complete Matplotlib Tutorial, refer Matplotlib Tutorial
SeaBall
Seaborn là một giao diện cấp cao được xây dựng trên đỉnh của matplotlib. Nó cung cấp phong cách thiết kế đẹp và bảng màu để tạo ra các biểu đồ hấp dẫn hơn.is a high-level interface built on top of the Matplotlib. It provides beautiful design styles and color palettes to make more attractive graphs.
Để cài đặt Seaborn Loại lệnh dưới đây trong thiết bị đầu cuối.
pip install seaborn
Seaborn được xây dựng trên đỉnh của matplotlib, do đó nó cũng có thể được sử dụng với matplotlib. Sử dụng cả matplotlib và Seaborn cùng nhau là một quá trình rất đơn giản. Chúng ta chỉ cần gọi chức năng âm mưu trên biển như bình thường, và sau đó chúng ta có thể sử dụng chức năng tùy chỉnh Matplotlib.
Lưu ý: Seaborn được tải với bộ dữ liệu như mẹo, mống mắt, v.v. Nhưng vì mục đích của hướng dẫn này, chúng tôi sẽ sử dụng gấu trúc để tải các bộ dữ liệu này. Seaborn comes loaded with dataset such as tips, iris, etc. but for the sake of this tutorial we will use Pandas for loading these datasets.
Example:
Python3
import
pip install seaborn39
import
pip install seaborn7
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pip install seaborn49
=
pip install seaborn51
pip install seaborn52
=
pip install seaborn54
pip install seaborn55
=
pip install seaborn57
pip install bokeh8
pip install seaborn59
pip install seaborn0
pip install plotly7
Output:
Cốt truyện phân tán
Biểu đồ phân tán được vẽ bằng cách sử dụng phương thức scatterplot []. Điều này tương tự như matplotlib, nhưng cần có dữ liệu đối số bổ sung.scatterplot[] method. This is similar to Matplotlib, but additional argument data is required.
Example:
Python3
import
pip install seaborn39
import
pip install seaborn7
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pip install seaborn73
=
pip install bokeh4
pip install seaborn52
=
pip install bokeh6
pip install seaborn55
=
pip install seaborn81
pip install plotly7
Output:
pip install bokeh8
pip install seaborn59
pip install seaborn0
Example:
Python3
import
pip install seaborn39
import
pip install seaborn7
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pip install seaborn73
=
pip install bokeh4
pip install seaborn52
=
pip install bokeh6
pip install seaborn55
=
pip install bokeh02
pip install bokeh03
pip install bokeh04
=
pip install bokeh06
pip install seaborn0
pip install plotly7
Output:
pip install bokeh
8pip install seaborn
59pip install seaborn
0
Cốt truyện phân tánlineplot[] method. In this, we can pass only the data argument also.
Example:
Python3
import
pip install seaborn39
import
pip install seaborn7
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pip install seaborn49
=
pip install bokeh4
pip install seaborn52
=
pip install bokeh6
pip install seaborn55
=
pip install seaborn57
pip install plotly7
Output:
pip install bokeh
8pip install seaborn
59pip install seaborn
0
Python3
import
pip install seaborn39
import
pip install seaborn7
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pip install bokeh41
=
pip install bokeh43
data
0pip install bokeh45
=
pip install bokeh47
pip install seaborn3
pip install plotly7
Output:
pip install bokeh
8pip install seaborn
59pip install seaborn
0
Cốt truyện phân tánbarplot[] method.
Example:
Python3
import
pip install seaborn39
import
pip install seaborn7
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pip install bokeh8
pip install seaborn59
pip install seaborn0
pandas as pd
6
pip install bokeh04
=
pip install bokeh06
pip install seaborn0
pip install plotly7
Output:
Cốt truyện phân tán
Biểu đồ phân tán được vẽ bằng cách sử dụng phương thức scatterplot []. Điều này tương tự như matplotlib, nhưng cần có dữ liệu đối số bổ sung.histplot[] function.
Example:
Python3
import
pip install seaborn39
import
pip install seaborn7
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pip install bokeh87
=
data
0pip install seaborn55
=
pip install bokeh92
=
pip install bokeh94
pip install bokeh95
=
pip install bokeh06
pip install seaborn0
pip install plotly7
Output:
pip install bokeh8
pip install seaborn59
pip install seaborn0
Cốt truyện phân tánFor complete Seaborn Tutorial, refer Python Seaborn Tutorial
Biểu đồ phân tán được vẽ bằng cách sử dụng phương thức scatterplot []. Điều này tương tự như matplotlib, nhưng cần có dữ liệu đối số bổ sung.
Bạn sẽ thấy rằng trong khi sử dụng matplotlib, nó sẽ khó khăn rất nhiều nếu bạn muốn tô màu từng điểm của cốt truyện này theo giới tính. Nhưng trong sơ đồ phân tán, nó có thể được thực hiện với sự trợ giúp của đối số Huế.
Line Lô
pip install bokeh
Cốt truyện phân tán
Biểu đồ phân tán được vẽ bằng cách sử dụng phương thức scatterplot []. Điều này tương tự như matplotlib, nhưng cần có dữ liệu đối số bổ sung.
Example:
Python3
Bạn sẽ thấy rằng trong khi sử dụng matplotlib, nó sẽ khó khăn rất nhiều nếu bạn muốn tô màu từng điểm của cốt truyện này theo giới tính. Nhưng trong sơ đồ phân tán, nó có thể được thực hiện với sự trợ giúp của đối số Huế.
Line Lô
import
pandas as pd
pip install bokeh8
pip install seaborn59
pip install seaborn0
data
=
pd.read_csv[
"tips.csv"
____10
Cốt truyện phân tán
pip install plotly26
data
0pip install bokeh5
pip install bokeh6
pip install plotly30
=
pip install plotly32
pip install plotly33
Output:
Biểu đồ phân tán được vẽ bằng cách sử dụng phương thức scatterplot []. Điều này tương tự như matplotlib, nhưng cần có dữ liệu đối số bổ sung.
Bạn sẽ thấy rằng trong khi sử dụng matplotlib, nó sẽ khó khăn rất nhiều nếu bạn muốn tô màu từng điểm của cốt truyện này theo giới tính. Nhưng trong sơ đồ phân tán, nó có thể được thực hiện với sự trợ giúp của đối số Huế.
Example:
Python3
pip install plotly00
pip install plotly01
import
pip install plotly03
import
pandas as pd
pip install plotly10
=
pip install plotly12
=
pip install plotly444____10
data
=
pd.read_csv[
"tips.csv"
____10
pip install plotly51
=
pandas as pd
3pip install bokeh6
pip install plotly55
pip install plotly56
pip install bokeh6
pip install bokeh7
pip install plotly33
Output:
Biểu đồ cột
Biểu đồ thanh có thể có hai loại thanh ngang và thanh dọc. Mỗi có thể được tạo bằng các hàm hbar [] và vbar [] của giao diện âm mưu tương ứng.
Example:
Python3
pip install plotly00
pip install plotly01
import
pip install plotly03
import
pandas as pd
pip install plotly10
=
pip install plotly12
=
pip install plotly444____10
data
=
pd.read_csv[
"tips.csv"
____10
pip install plotly77
data
0pip install plotly79
=
pandas as pd
3pip install bokeh6
pip install bokeh7
pip install plotly33
Output:
pip install plotly
51=
pandas as pd
3pip install bokeh
6pip install plotly
55
Biểu đồ cột
Biểu đồ thanh có thể có hai loại thanh ngang và thanh dọc. Mỗi có thể được tạo bằng các hàm hbar [] và vbar [] của giao diện âm mưu tương ứng.
Trực quan hóa dữ liệu tương tác property makes the legend interactive. There are two types of interactivity –
- Một trong những tính năng chính của Bokeh là thêm tương tác vào các lô. Hãy cùng xem các tương tác khác nhau có thể được thêm vào. Hides the Glyphs.
- Truyền thuyết tương tác Hiding the glyph makes it vanish completely, on the other hand, muting the glyph just de-emphasizes the glyph based on the parameters.
Example:
Python3
pip install plotly00
pip install plotly01
import
pip install plotly03
import
pandas as pd
pip install plotly10
=
pip install plotly12
=
pip install plotly444____10
data
=
pd.read_csv[
"tips.csv"
____10
pip install plotly77
data
0pip install plotly79
=
pandas as pd
3pip install bokeh6
pandas as pd
5pip install plotly51
=
pandas as pd
3pip install bokeh6
pip install plotly55
pip install plotly77
pip install bokeh6
pip install plotly79
=
pandas as pd
3pandas as pd
4pandas as pd
5Biểu đồ cột
Biểu đồ thanh có thể có hai loại thanh ngang và thanh dọc. Mỗi có thể được tạo bằng các hàm hbar [] và vbar [] của giao diện âm mưu tương ứng.
pip install plotly33
Output:
Trực quan hóa dữ liệu tương tác
Một trong những tính năng chính của Bokeh là thêm tương tác vào các lô. Hãy cùng xem các tương tác khác nhau có thể được thêm vào.
- Truyền thuyết tương tácThis widget adds a simple button widget to the plot. We have to pass a custom JavaScript function to the CustomJS[] method of the models class.
- thuộc tính click_policy làm cho truyền thuyết tương tác. Có hai loại tương tác - Adds a standard check box to the plot. Similarly to buttons we have to pass the custom JavaScript function to the CustomJS[] method of the models class.
- HIDING: ẩn các glyphs.Adds a simple radio button and accepts a custom JavaScript function.
Example:
Python3
Đột biến: Việc che giấu glyph làm cho nó biến mất hoàn toàn, mặt khác, tắt tiếng glyph chỉ để nhấn mạnh glyph dựa trên các tham số.
Các
Các
import
50
import
51import
52=
import
54
pip install seaborn3
import
32=
import
34
Thêm widget
import
76=
pip install seaborn3
Bokeh cung cấp các tính năng GUI tương tự như các biểu mẫu HTML như nút, thanh trượt, hộp kiểm, v.v ... Chúng cung cấp giao diện tương tác cho lô cho phép thay đổi các tham số của lô, sửa đổi dữ liệu lô, v.v. widgets. & nbsp;
import
87=
pip install seaborn3
import
90
import
91
import
92
Output:
Các nút: Tiện ích này thêm một tiện ích nút đơn giản vào cốt truyện. Chúng ta phải chuyển hàm javascript tùy chỉnh cho phương thức CustomJS [] của lớp mô hình.All these buttons will be opened on a new tab.
- Checkboxgroup: Thêm hộp kiểm tiêu chuẩn vào lô. Tương tự như các nút, chúng ta phải chuyển chức năng JavaScript tùy chỉnh cho phương thức CustomJS [] của lớp Mô hình. Adds a slider to the plot. It also needs a custom JavaScript function.
Example:
Python3
Đột biến: Việc che giấu glyph làm cho nó biến mất hoàn toàn, mặt khác, tắt tiếng glyph chỉ để nhấn mạnh glyph dựa trên các tham số.
Các
Các
pandas as pd
19pandas as pd
20pandas as pd
21=
pip install seaborn3
pandas as pd
24
Output:
import
32=
import
34
Thêm widget For complete Bokeh tutorial, refer Python Bokeh tutorial – Interactive Data Visualization with Bokeh
Bokeh cung cấp các tính năng GUI tương tự như các biểu mẫu HTML như nút, thanh trượt, hộp kiểm, v.v ... Chúng cung cấp giao diện tương tác cho lô cho phép thay đổi các tham số của lô, sửa đổi dữ liệu lô, v.v. widgets. & nbsp;
Các nút: Tiện ích này thêm một tiện ích nút đơn giản vào cốt truyện. Chúng ta phải chuyển hàm javascript tùy chỉnh cho phương thức CustomJS [] của lớp mô hình.
- Checkboxgroup: Thêm hộp kiểm tiêu chuẩn vào lô. Tương tự như các nút, chúng ta phải chuyển chức năng JavaScript tùy chỉnh cho phương thức CustomJS [] của lớp Mô hình.
- RadioGroup: Thêm nút radio đơn giản và chấp nhận chức năng JavaScript tùy chỉnh.
pip install plotly
00import
37import
import
39
pip install plotly00
import
41import
import
43pip install plotly
import
44=
import
46=
import
48pip install seaborn
0
import
56=
import
58import
59import
60import
61import
60import
63import
64scatter[] method of plotly.express. Like Seaborn, an extra data argument is also required here.
Example:
Python3
import
65=
import
67=
import
69__7import
58import
72import
60import
7474
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
import
79=
import
81=
import
69____________
pip install bokeh47____10
pandas as pd
46
Output:
Lưu ý: Tất cả các nút này sẽ được mở trên một tab mới.
Sliders: Thêm một thanh trượt vào cốt truyện. Nó cũng cần một chức năng JavaScript tùy chỉnh.px.line each data position is represented as a vertex
Example:
Python3
import
pandas as pd
26
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pandas as pd
34=
pandas as pd
58=
pip install bokeh6
import
13=
pip install bokeh06____10
pandas as pd
46
Output:
Biểu đồ cột
Biểu đồ thanh trong Plotly có thể được tạo bằng phương thức Bar [] của lớp Plotly.Express.
Example:
Python3
import
pandas as pd
26
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pandas as pd
34=
pandas as pd
58=
pip install bokeh6
import
13=
pip install bokeh06____10
pandas as pd
46
Output:
Biểu đồ cột
Biểu đồ thanh trong Plotly có thể được tạo bằng phương thức Bar [] của lớp Plotly.Express.
Example:
Python3
import
pandas as pd
26
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pandas as pd
34=
pandas as pd
58=
pip install bokeh6
import
13=
pip install bokeh06____10
pandas as pd
46
Output:
Biểu đồ cột
Biểu đồ thanh trong Plotly có thể được tạo bằng phương thức Bar [] của lớp Plotly.Express.
Các: A drop-down menu is a part of the menu-button which is displayed on a screen all the time. Every menu button is associated with a Menu widget that can display the choices for that menu button when clicked on it. In plotly, there are 4 possible methods to modify the charts by using updatemenu method.
- Biểu đồ modify data or data attributes
- Trong cốt truyện, biểu đồ có thể được tạo bằng hàm biểu đồ [] của lớp Plotly.Express. modify layout attributes
pandas as pd
34=
pandas as pd
99=
data
0import
13=
pip install bokeh
06____10 modify data and layout attributes- Thêm tương tác start or pause an animation
Example:
Python3
Giống như Bokeh, Plotly cũng cung cấp các tương tác khác nhau. Hãy để thảo luận về một vài trong số họ.
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pandas as pd
34=
pandas as pd
58=
pip install bokeh6
import
13=
pip install bokeh06____10
import
51data
22=
pandas as pd
3
pip install bokeh4
pandas as pd
5import
51data
28=
pandas as pd
3
pip install bokeh6
pandas as pd
5import
51data
34=
data
36data
37
pip install bokeh7
data
39
import
51data
41=
import
58
data
44data
45data
46
Biểu đồ cột
data
52data
45data
46
data
55data
56=
import
58data
59import
60data
61pandas as pd
5
data
55data
64=
pip install bokeh9
data
67data
55data
69=
data
71
data
52data
73
data
52data
45data
46
data
55data
56=
import
58data
59import
60data
83pandas as pd
5
data
55data
64=
pip install seaborn13
data
67data
55data
69=
data
71
data
52
pip install seaborn0
pandas as pd
6data
97
pandas as pd
6data
99=
=
01data
67
Biểu đồ thanh trong Plotly có thể được tạo bằng phương thức Bar [] của lớp Plotly.Express.
import
51import
64
pip install seaborn0
=
08
Output:
Các: In plotly, actions custom Buttons are used to quickly make actions directly from a record. Custom Buttons can be added to page layouts in CRM, Marketing, and Custom Apps. There are also 4 possible methods that can be applied in custom buttons:
- Biểu đồ modify data or data attributes
- Trong cốt truyện, biểu đồ có thể được tạo bằng hàm biểu đồ [] của lớp Plotly.Express. modify layout attributes
pandas as pd
34=
pandas as pd
99=
data
0import
13=
pip install bokeh
06____10 modify data and layout attributes- Thêm tương tác start or pause an animation
Example:
Python3
Giống như Bokeh, Plotly cũng cung cấp các tương tác khác nhau. Hãy để thảo luận về một vài trong số họ.
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
pandas as pd
34=
pandas as pd
58=
pip install bokeh6
import
13=
pip install bokeh06____10
import
51data
22=
pandas as pd
3
pip install bokeh4
pandas as pd
5import
51data
28=
pandas as pd
3
pip install bokeh6
pandas as pd
5import
51data
34=
data
36data
37
pip install bokeh7
data
39
import
51data
41=
import
58
data
44data
45data
46
pandas as pd
6=
50=
=
52data
67
pandas as pd
6data
99=
=
57data
67
Biểu đồ cột
data
52data
45data
46
data
55data
56=
import
58data
59import
60data
61pandas as pd
5
data
55data
64=
pip install bokeh9
data
67data
55data
69=
data
71
data
52data
73
data
52data
45data
46
data
55data
56=
import
58data
59import
60data
83pandas as pd
5
data
55data
64=
pip install seaborn13
data
67data
55data
69=
data
71
data
52
pip install seaborn0
pandas as pd
6data
97
data
44data
73
import
51import
64
Biểu đồ thanh trong Plotly có thể được tạo bằng phương thức Bar [] của lớp Plotly.Express.
=
08
Output:
Các
Biểu đồ
Example:
Python3
import
data
08
import
pandas as pd
data
=
pd.read_csv[
"tips.csv"
____10
data
16=
data
18=
data
20
import
51data
28=
pandas as pd
3
pip install bokeh6
pandas as pd
5import
51data
34=
pd.read_csv[
39data
37
pip install bokeh7
data
39
import
51pd.read_csv[
44=
data
45data
46
data
44pd.read_csv[
49=
data
45data
46
pandas as pd
6data
48=
data
50data
51
data
52data
45pd.read_csv[
60=
pip install bokeh47
data
67data
55pd.read_csv[
65=
pandas as pd
38data
67
data
55pd.read_csv[
70=
pd.read_csv[
72data
73
pandas as pd
6
pip install bokeh7
data
44data
73
data
44pd.read_csv[
79=
data
45data
46
pandas as pd
6pd.read_csv[
84=
pip install bokeh94
data
44data
73
import
51
pip install seaborn0
pip install seaborn0
=
08
Output:
LƯU Ý: Để biết hướng dẫn hoàn chỉnhFor complete Plotly tutorial, refer Python Plotly tutorial
Sự kết luận
Trong hướng dẫn này, chúng tôi đã vẽ các bộ dữ liệu TIP với sự trợ giúp của bốn mô -đun âm mưu khác nhau của Python là Matplotlib, Seaborn, Bokeh và Plotly. Mỗi mô-đun cho thấy cốt truyện theo cách riêng của mình và mỗi mô-đun có bộ tính năng riêng như matplotlib mang lại sự linh hoạt hơn nhưng với chi phí viết nhiều mã hơn trong khi Seaborn là ngôn ngữ cấp cao cung cấp cho phép người ta đạt được cùng một mục tiêu với một mục tiêu với Một lượng nhỏ mã. Mỗi mô -đun có thể được sử dụng tùy thuộc vào nhiệm vụ chúng tôi muốn làm.