Skip to content

Instantly share code, notes, and snippets.

@zh3389
Created April 28, 2024 08:38
Show Gist options
  • Save zh3389/f11f34ea008663b99241dffe92fcca31 to your computer and use it in GitHub Desktop.
Save zh3389/f11f34ea008663b99241dffe92fcca31 to your computer and use it in GitHub Desktop.
数据可视化自动化利用Matplotlib库,实现数据的自动图表生成。
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