首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >python画图

python画图

作者头像
py3study
发布2020-01-10 17:08:50
发布2020-01-10 17:08:50
1.8K0
举报
文章被收录于专栏:python3python3
代码语言:javascript
复制
#!/bin/env python
#coding=utf8
'''
function: show total of all data in one picture 
write: zhanglejie
date: 2015/09/22
'''
import numpy as np
import pylab as pl
import string
import matplotlib.ticker as ticker
from matplotlib.dates import DayLocator, HourLocator, DateFormatter, drange
from datetime import datetime,timedelta
from matplotlib.dates import AutoDateLocator, DateFormatter  
from matplotlib.font_manager import FontProperties
from matplotlib.ticker import MultipleLocator,FormatStrFormatter

#define font of chinese
font = FontProperties(fname="/usr/share/fonts/cjkuni-ukai/ukai.ttc", size=15) 
font_small = FontProperties(fname="/usr/share/fonts/cjkuni-ukai/ukai.ttc", size=13) 
#define picture size
pl.figure(figsize=(15,8), dpi=60)
pl.subplots_adjust(bottom=0.060, left=0.035, top=0.975, right=0.958)
#split picture to two
ax1 = pl.subplot(311)
ax2 = pl.subplot(312)
ax3 = pl.subplot(313)
ax1.grid(True)  #show grid
ax2.grid(True)
ax3.grid(True)

#
#define 
x_time = np.linspace(14,1,14,endpoint=True)  
#x_time = []
y_active = []
y_new = []
y_earn_money = []
y_new_vip = []
y_new_register = []
y_new_point = []
y_used_point = []
y_all_point = []
y_new_payer = []
y_all_payer = []

#
for line in file('/tmp/pic_data.txt'):
  if string.strip(line) != '':
    info = line.split()
#    x_time.append(info[0])
    y_active.append(info[1])
    y_new.append(info[2])
    y_earn_money.append(info[4])
    y_new_vip.append(info[5])
    y_new_register.append(info[6])
    y_new_point.append(info[7])
    y_used_point.append(info[8][1:])
    y_new_payer.append(info[9])
    y_all_point.append(info[10])
    y_all_payer.append(info[11])

#print x_time
#
#
#pl.title(u'报告',fontproperties=font)
pl.xlabel(u'几天前',fontproperties=font)
#
ax1.xaxis.set_major_locator(MultipleLocator(1))
ax1.yaxis.set_major_locator(MultipleLocator(150))
ax1.plot(x_time, y_active,'o-',color='blue',linewidth=2.5,label=u'活跃用户')
ax1.plot(x_time, y_all_payer,'o-',color='darkcyan',linewidth=2.5,label=u'总付费用户')
ax1.legend(loc='best', frameon=False,prop=font_small)
#
ax2.xaxis.set_major_locator(MultipleLocator(1))
ax2.yaxis.set_major_locator(MultipleLocator(10))
ax2.plot(x_time, y_new_register,'o-',color='blue',linewidth=2.5,label=u'新增注册')
ax2.plot(x_time, y_new_vip,'o-',color='red',linewidth=2.5,label=u'新增会员')
ax2.plot(x_time, y_new,'o-',color='green',linewidth=2.5,label=u'新增用户')
ax2.plot(x_time, y_earn_money,'o-',color='magenta',linewidth=2.5,label=u'收入')
ax2.plot(x_time, y_new_payer,'o-',color='darkmagenta',linewidth=2.5,label=u'新增付费用户')
ax2.legend(loc='best', frameon=False,prop=font_small)
#
ax3.xaxis.set_major_locator(MultipleLocator(1))
ax3.yaxis.set_major_locator(MultipleLocator(5000))
ax3.plot(x_time, y_new_point,'o-',color='blue',linewidth=2.5,label=u'新增积分')
ax3.plot(x_time, y_used_point,'o-',color='red',linewidth=2.5,label=u'消耗积分')
ax3.plot(x_time, y_all_point,'o-',color='green',linewidth=2.5,label=u'总积分')
ax3.legend(loc='best', frameon=False,prop=font_small)
#
pl.savefig("/tmp/all_data.png")
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/08/29 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档