import numpy as np import matplotlib.pyplot as plt

創建一個 Numpy 數組,包含時間和發文次數

data = np.array([[2014, 18], [2015, 17], [2016, 19], [2017, 10], [2018, 10], [2019, 13], [2020, 6], [2021, 8], [2022, 5]])

按照發文次數降序排序

data = data[data[:, 1].argsort()[::-1]]

繪製數據可視化圖表

plt.bar(data[:, 0], data[:, 1]) plt.xlabel('Year') plt.ylabel('Number of Posts') plt.title('Posts Per Year') plt.show()

使用 Python 和 Numpy 處理發文次數數據並進行可視化

原文地址: https://www.cveoy.top/t/topic/oYGl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录