由下面的test_01.csv文件生成图表。
name,date,A,B,C
one,2020/4/1,1,2,3
one,2020/4/2,5,3,1
one,2020/4/3,6,3,4
生成的图表是下面这个样子。
x轴的地方是“date”,但我想要把x轴上的刻度用日期“2020/4/1”等显示出来。
请问用什么办法可以实现吗?
代码:
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import datetime
fileName = 'test_01.csv'
df = pd.read_csv(fileName)
df.set_index(df['date']).plot.area()
plt.legend(loc='upper left', bbox_to_anchor=(1, 1))
plt.savefig(fileName.replace('.csv','.png'), bbox_inches='tight')
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
https://www.cnblogs.com/pythonywy/p/11019263.html,看看你应该就会了