- 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:

推薦閱讀
- Web程序設計及應用
- 自然語言處理實戰(zhàn):預訓練模型應用及其產(chǎn)品化
- PostgreSQL for Data Architects
- 動手玩轉Scratch3.0編程:人工智能科創(chuàng)教育指南
- C語言程序設計教程(第2版)
- 數(shù)據(jù)庫系統(tǒng)原理及MySQL應用教程
- Essential Angular
- Elastic Stack應用寶典
- Mastering macOS Programming
- 深度學習:算法入門與Keras編程實踐
- HTML5+CSS3+JavaScript Web開發(fā)案例教程(在線實訓版)
- The Complete Coding Interview Guide in Java
- 從Excel到Python:用Python輕松處理Excel數(shù)據(jù)(第2版)
- 響應式架構:消息模式Actor實現(xiàn)與Scala、Akka應用集成
- Webpack實戰(zhàn):入門、進階與調(diào)優(yōu)(第2版)