1. 程式人生 > 其它 >資料視覺化-Rosea海霞

資料視覺化-Rosea海霞

技術標籤:資料視覺化

Task01 - Matplotlib初相識

  • 簡單繪圖例子

import matplotlib.pyplot as plt
import numpy as np
#OO模式實現
fig, ax = plt.subplots() # 建立一個包含一個axes的figure
ax.plot([1, 2, 3, 4], [1, 4, 2, 3]) # 繪製圖像
#pyplot模式實現
plt.plot([1, 2, 3, 4], [1, 4, 2, 3]) 

  • 兩種繪圖介面

import matplotlib.pyplot as plt
import numpy as np

#OO模式實現
x = np.linspace(0, 2, 100)

fig, ax = plt.subplots()  
ax.plot(x, x, label='linear')  
ax.plot(x, x**2, label='quadratic')  
ax.plot(x, x**3, label='cubic')  
ax.set_xlabel('x label') 
ax.set_ylabel('y label') 
ax.set_title("Simple Plot-OO")  
ax.legend() 


#pyplot模式實現
x = np.linspace(0, 2, 100)

plt.plot(x, x, label='linear') 
plt.plot(x, x**2, label='quadratic')  
plt.plot(x, x**3, label='cubic')
plt.xlabel('x label')
plt.ylabel('y label')
plt.title("Simple Plot-pyplot")
plt.legend()

作業

你在工作或學習中通常何時會用到資料視覺化,希望通過視覺化達到什麼目的?

最常見的是資料初始化、加工清洗及分析之後,通過資料視覺化呈現。

希望通過視覺化達到目的:這必須是先達到學習的目的呀,然後輔助業務更加清晰,完成專案管理,讓甲方爸爸們開心呀~~~