- matplotlib Plotting Cookbook
- Alexandre Devert
- 176字
- 2021-07-16 12:16:25
Plotting points
When displaying a curve, we implicitly assume that one point follows another—our data is the time series. Of course, this does not always have to be the case. One point of the data can be independent from the other. A simple way to represent such kind of data is to simply show the points without linking them.
How to do it...
The following script displays 1024 points whose coordinates are drawn randomly from the [0,1] interval:
import numpy as np import matplotlib.pyplot as plt data = np.random.rand(1024, 2) plt.scatter(data[:,0], data[:,1]) plt.show()
The preceding script will produce the following graph:

How it works...
The function plt.scatter()
works exactly like plt.plot()
, taking the x and y coordinates of points as input parameters. However, each point is simply shown with one marker. Don't be fooled by this simplicity—plt.scatter()
is a rich command. By playing with its many optional parameters, we can achieve many different effects. We will cover this in Chapter 2, Customizing the Color and Styles, and Chapter 3, Working with Annotations.
- 手機安全和可信應用開發指南:TrustZone與OP-TEE技術詳解
- Progressive Web Apps with React
- Python從菜鳥到高手(第2版)
- Mastering Articulate Storyline
- C#程序設計教程
- 鋒利的SQL(第2版)
- .NET 3.5編程
- Unity 3D腳本編程:使用C#語言開發跨平臺游戲
- PrimeFaces Blueprints
- Java Web開發教程:基于Struts2+Hibernate+Spring
- Java 7 Concurrency Cookbook
- 循序漸進Vue.js 3前端開發實戰
- HTML5+jQuery Mobile移動應用開發
- 微信小程序開發圖解案例教程:附精講視頻(第3版)
- Web 2.0策略指南