绘图的简单示例

绘图的简单示例

  • matplotlib API绘制

简单的示例代码。包括设置xy轴的间距,label以及标签名

import matplotlib.pyplot as plt
import numpy as np
from numpy.random import randn

fig,axes = plt.subplots()
axes.set_xlim([0,12])
axes.set_xticks([0,2,4,6,8,10,12])
axes.set_xticklabels(['start-page','connect-page','annual','wechat','qq','weibo','unknown'],fontsize='small',rotation=30)
axes.set_xlabel('from')
axes.set_title('year-end-activity')
axes.plot([0,2,4,6,8,10,12],[100,200,300,500,900,200,800],'k--',label='2016-01-06',marker='o')
axes.plot([0,2,4,6,8,10,12],[200,100,400,600,300,200,1600],'k-',label='2016-01-07',marker='x')
axes.legend(loc='best')
plt.savefig('C:\\Users\\acer\\Desktop\\LOCAL-REPO\\annual.png',dpi=400,bbox_inches='tight')
fig.show()

你可能感兴趣的:(绘图的简单示例)