Python繪製溫度變化曲線

2022-02-02 07:58:01 字數 1814 閱讀 3898

from requests import get
import matplotlib.pyplot as plt
/usr/lib/python3/dist-packages/matplotlib/font_manager.py:273: userwarning: matplotlib is building the font cache using fc-list. this may take a moment.

warnings.warn('matplotlib is building the font cache using fc-list. this may take a moment.')

/usr/lib/python3/dist-packages/matplotlib/font_manager.py:273: userwarning: matplotlib is building the font cache using fc-list. this may take a moment.

warnings.warn('matplotlib is building the font cache using fc-list. this may take a moment.')

from dateutil import parser
url = ''
weather = get(url).json()
weather['items'][0]['ambient_temp']
9.77
weather['items'][0]
temperatures = 

for record in weather['items']:

temperature = record['ambient_temp']

temperatures = [record['ambient_temp'] for record in weather['items']]
parser.parse(weather['items'][0]['reading_timestamp'])
datetime.datetime(2016, 11, 19, 22, 50, tzinfo=tzutc())
timestamps = [parser.parse(record['reading_timestamp']) for record in weather['items']]
繪圖需要的**很少,首先宣告繪圖要用的資料集合,然後第二個用來展示資料:

## 繪製溫度時間變化圖

plt.plot(timestamps, temperatures)

plt.ylabel('溫度')

plt.xlabel('時間')

到此為止教程結束

比如物理的加速度實驗,用紙袋獲取資料後可以用這種方法繪圖

生物實驗觀測的資料繪圖

數學影象,統計觀察

python 繪製ROC曲線

簡述 機器學習很多是為測試樣本產生乙個 值,然後將這個 值與閾值進行對比,若大於閾值則分為正類,否則分為反類。這個 值的好壞,直接決定了學習器泛化能力。根據這個 值,我們可以對測試樣本進行排序,最可能 是正例的排在最前面,最不可能 是正例的排在最後面。這樣,分類過程就相當於在這個排序中以某個截斷點將...

Python動態繪製曲線

python動態繪製曲線 import numpy as np import matplotlib.pyplot as plt num 100index 0data np.zeros num 初始化 for i in range 10000 index index 0.1 adddata np.si...

Python學習 ROC曲線繪製

from sklearn.metrics import roc curve 匯入roc曲線函式 fpr,tpr,thresholds roc curve test 3 tree.predict proba test 3 1 pos label 1 test 3 測試集真實標記值 tree.predi...