import pandas as pd from pandas import DataFrame import matplotlib.pyplot as plt data={'鱼号':['f1','f2','f3','f4','f5'], '鱼名':['鲤鱼','草鱼','鲫鱼','鳙鱼','黑鱼'], '习性':['杂食性','食草性','温水性','温水性','肉食性'], '产量':[300,240,500,400,480]} print(DataFrame(data)) plt.figure(figsize=(6,8)) plt.plot(x='鱼名',y='产量',label=data['产量'],color='red') plt.xlabel('鱼名') plt.xlabel('产量') plt.title('淡水鱼产量统计图') plt.legend() plt.show()帮我改一下这段代码
时间: 2023-07-14 11:12:52 浏览: 50
10分钟搞定pandas.docx
import pandas as pd
from pandas import DataFrame
import matplotlib.pyplot as plt
data={
'鱼号':['f1','f2','f3','f4','f5'],
'鱼名':['鲤鱼','草鱼','鲫鱼','鳙鱼','黑鱼'],
'习性':['杂食性','食草性','温水性','温水性','肉食性'],
'产量':[300,240,500,400,480]
}
df = DataFrame(data)
plt.figure(figsize=(6,8))
plt.plot(df['鱼名'], df['产量'], label='产量', color='red')
plt.xlabel('鱼名')
plt.ylabel('产量')
plt.title('淡水鱼产量统计图')
plt.legend()
plt.show()
阅读全文