余姿函的學習歷程 - 大數據 - 9.時間序列圖 |
|
|
9.時間序列圖時間序列圖https://colab.research.google.com/drive/1v26WT9MahjBVG4VIPNnXEj0f26OEhoA4?usp=share_linkimport numpy as np import seaborn as sns import pandas as pd import matplotlib.pyplot as plt # 建立資料 my_count = ["France", "Australia", "Japan", "USA", "Germany", "Congo", "China", "England", "Spain", "Greece", "Marocco", "South Africa", "Indonesia", "Peru", "Chili", "Brazil"] df = pd.DataFrame({ "country": np.repeat(my_count, 10), "years": list(range(2000, 2010)) * 16, "value": np.random.rand(160) }) # 建立網格 g = sns.FacetGrid(df, col='country', hue='country', col_wrap=4, ) # 新增曲線圖 g = g.map(plt.plot, 'years', 'value') # 面積圖 g = g.map(plt.fill_between, 'years', 'value', alpha=0.2).set_titles("{col_name} country") # 標題 g = g.set_titles("{col_name}") # 總標題 plt.subplots_adjust(top=0.92) g = g.fig.suptitle('Evolution of the value of stuff in 16 countries') # 顯示
|
|
中華科技大學數位化學習歷程 - 意見反應 |