Created
April 28, 2024 08:38
-
-
Save zh3389/f11f34ea008663b99241dffe92fcca31 to your computer and use it in GitHub Desktop.
数据可视化自动化利用Matplotlib库,实现数据的自动图表生成。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import pandas as pd | |
def visualize_data(data_file): | |
df = pd.read_csv(data_file) | |
# 示例:绘制柱状图 | |
df.plot(kind='bar', x='category', y='value') | |
plt.title('数据分布') | |
plt.xlabel('类别') | |
plt.ylabel('值') | |
plt.show() | |
# 使用示例: | |
visualize_data('data.csv') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment