- Matplotlib for Python Developers
- Aldrin Yim Claire Chung Allen Yu
- 102字
- 2021-08-27 18:48:20
Scatter plot
Another basic plot type is scatter plot, a plot of dots. You can draw it by calling plt.scatter(x,y). The following example shows a scatter plot of random dots:
import numpy as np
import matplotlib.pyplot as plt
# Set the random seed for NumPy function to keep the results reproducible
np.random.seed(42)
# Generate a 2 by 100 NumPy Array of random decimals between 0 and 1
r = np.random.rand(2,100)
# Plot the x and y coordinates of the random dots on a scatter plot
plt.scatter(r[0],r[1])
# Show the plot
plt.show()
The following plot is the result of the preceding code:

推薦閱讀
- 新編Visual Basic程序設計上機實驗教程
- iOS Game Programming Cookbook
- Java完全自學教程
- Windows系統(tǒng)管理與服務配置
- 軟件測試項目實戰(zhàn)之性能測試篇
- Practical DevOps
- 精通API架構:設計、運維與演進
- C語言程序設計案例精粹
- 精通網(wǎng)絡視頻核心開發(fā)技術
- JavaScript 程序設計案例教程
- Flutter跨平臺開發(fā)入門與實戰(zhàn)
- Mobile Device Exploitation Cookbook
- Service Mesh實戰(zhàn):基于Linkerd和Kubernetes的微服務實踐
- Mockito Essentials
- 分布式架構原理與實踐