Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Trong hướng dẫn trước của chúng tôi,  Làm sạch dữ liệu Python . Hôm nay, chúng ta sẽ chơi với Hướng dẫn Python Matplotlib và Cốt truyện Python. Hơn nữa, chúng ta sẽ thảo luận về Pyplot, Chuỗi từ khóa và Các biến số phân loại của Python Plotting. Cuối cùng, chúng tôi sẽ đề cập đến các thuộc tính Line và một số ví dụ về Python Matplotlib.

Các bài viết liên quan:

Vì vậy, hãy bắt đầu Hướng dẫn Python Matplotlib.

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

  • Python Matplotlib là gì?
  • Hướng dẫn Python Matplotlib – Điều kiện tiên quyết
    • Python Matplotlib
    • Pandas
  • Hướng dẫn Python Matplotlib – Pyplot
    • plot()
    • Định dạng Python plot
  • Từ khóa Python Matplotlib
  • Các biến phân loại cho Python Plotting
  • Một số thuộc tính dòng của Matplotlib
    • Linewidth
    • Alpha
    • ChAntialiased
    • Color hoặc c
    • Dashes
    • Linestyle hoặc ls
    • Marker
    • Markeredgecolor
    • Markeredgewidth
    • Markerfacecolor và Markersize
    • Markevery
    • Zorder
  • Hiển thị Grid trong Python
  • Kết luận

Python Matplotlib là gì?

Hướng dẫn Python Matplotlib – Điều kiện tiên quyết

Python Matplotlib

  • Pandas
  • Hướng dẫn Python Matplotlib – Pyplot
  • Định dạng Python plot
  • Từ khóa Python Matplotlib
  • Các biến phân loại cho Python Plotting

Một số thuộc tính dòng của Matplotlib

  • Linewidth
  • Alpha
  • ChAntialiased

Hướng dẫn Python Matplotlib – Điều kiện tiên quyết

Python Matplotlib

Python Matplotlib

Pandas

Pandas

Hướng dẫn Python Matplotlib – Pyplot

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Định dạng Python plot

Hướng dẫn Python Matplotlib – Pyplot

Định dạng Python plot

plot()

Từ khóa Python Matplotlib

import matplotlib.pyplot as plt # khai báo  thư viện
plt.plot([2,3,4,5]) # tạo điểm trên bản đồ

plt.xlabel('Actual birth weight') # label x 

plt.ylabel('Estimated birth weight') # label y

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Các biến phân loại cho Python Plotting

Một số thuộc tính dòng của Matplotlib

plt.plot([2,3,4,5],[3,8,10,12])
plt.show()

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Linewidth

Định dạng Python plot

Từ khóa Python Matplotlib

plt.plot([2,3,4,5],[3,8,10,12],'gs') # khai báo đồ thị
plt.axis([0,7,0,21]) # khai báo trục x
plt.show() # vẽ ra đồ thị

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Các biến phân loại cho Python Plotting

import numpy as np # khai báo thư viện 
t=np.arange(0,5,0.2)
plt.plot(t,t,'r--',t,t**3,'b^',t,t**2,'gs') # vẽ đồ thị
plt.show() # vẽ ra đồ thị

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Từ khóa Python Matplotlib

Các biến phân loại cho Python Plotting

data={'a':np.arange(50),
'c':np.random.randint(0,50,50),
'd':np.random.randn(50)}
data['b']=data['a']+10*np.random.randn(50)
data['d']=np.abs(data['d'])*100
plt.scatter('a','b',c='c',s='d',data=data)
plt.show()

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Các biến phân loại cho Python Plotting

Một số thuộc tính dòng của Matplotlib

names=["Dingos","Wild Cats","Tigers"]
values=[1,11,111]
plt.figure(1,figsize=(9,3))
plt.subplot(131)
plt.bar(names,values)
plt.subplot(132)

plt.scatter(names,values)
plt.subplot(133)

plt.plot(names,values)
plt.suptitle('Varsity')
plt.show()

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Một số thuộc tính dòng của Matplotlib

Linewidth

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Linewidth

plt.xlabel('Actual birth weight') # label x 
0

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Alpha

ChAntialiased

plt.xlabel('Actual birth weight') # label x 
1

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

ChAntialiased

Color hoặc c

plt.xlabel('Actual birth weight') # label x 
2

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Color hoặc c

Dashes

plt.xlabel('Actual birth weight') # label x 
3

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Dashes

plt.xlabel('Actual birth weight') # label x 
4

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Linestyle hoặc ls

Marker

plt.xlabel('Actual birth weight') # label x 
5

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

plt.xlabel('Actual birth weight') # label x 
6

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Marker

Markeredgecolor

plt.xlabel('Actual birth weight') # label x 
7

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Markeredgecolor

Markeredgewidth

plt.xlabel('Actual birth weight') # label x 
8

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Markeredgewidth

Markerfacecolor và Markersize

plt.xlabel('Actual birth weight') # label x 
9

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Markerfacecolor và Markersize

Markevery

plt.ylabel('Estimated birth weight') # label y
0

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Markevery

Zorder

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

plt.ylabel('Estimated birth weight') # label y
1

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Zorder

Điều này cho phép chúng tôi quyết định ô nào sẽ hiển thị ở phía trước và ô nào sẽ hiển thị ở phía sau.

plt.ylabel('Estimated birth weight') # label y
2

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Trong biểu đồ này, trong khu vực được bao quanh bởi các điểm (1,2) và (2,4), cả hai ô đều bao gồm các điểm giống nhau, nhưng ô màu cam nằm ở phía trước. Điều này là do chúng tôi cung cấp cho nó một zorder cao hơn. Điều này giống như z-index trong CSS.

Hiển thị Grid trong Python

Bạn có thể sử dụng phương thức grid () để chuyển đổi một lưới trong biểu đồ của mình.

plt.ylabel('Estimated birth weight') # label y
3

Hướng dẫn matplotlib pyplot in python - matplotlib pyplot trong python

Vì vậy, đây là tất cả về Hướng dẫn Python Matplotlib. Hy vọng bạn thích giải thích của chúng tôi.

Kết luận

Do đó, chúng tôi đã nghiên cứu, Matplotlib, là Thư viện Python được sử dụng cho Python Plot và hơn thế nữa. Hơn nữa, nếu bạn có bất kỳ thông tin nào liên quan, hãy chia sẻ với chúng tôi.