EventCollectionDemo
EventCollections can be used to mark the locations of the x and y data points on the respective axes for each curve.
Fig1
Codes details
1. Load library
載入會使用到的函式庫àà 1.matplotlib 2.numpy
2. Fixing random state for reproducibility
np.random.seed()的作用是生成隨機數
當我們設置相同的seed時,每次生成的隨機數也相同,如果不設置seed,則每次生成的隨機數都會不一樣
例:
3.create random data
創造隨機的資料,下圖顯示資料內容
4. split the data into two parts
將數據分成兩個部分
5.sort the data so it makes clean curves
對數據進行排序,使其產生乾淨的曲線
6.create some y data points
創建一些y的數據點
7. plot the data
畫出數據
8.create the events marking the x data points
創建X數據點標記
9.create the events marking the y data points
創建Y數據點標記
10.add the events to the axis
增加軸
11.set the limits
設定限制和title名稱
12.display the plot
顯示圖出來