utils

parent d9d3e5a5
# -*- encoding: utf-8 -*-
# -----------------------------------------------------------------------------
# @File Name : draw.py
# @Time : 2020/11/19 上午10:51
# @Author : X. Peng
# @Email : acepengxiong@163.com
# @Software : PyCharm
# -----------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
def draw_stacked_column_chart():
"""堆叠柱状图"""
plt.title('Scores by group and gender')
N = 13
ind = np.arange(N) # [ 0 1 2 3 4 5 6 7 8 9 10 11 12]
plt.xticks(ind, ('G1', 'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'G9', 'G10', 'G11', 'G12', 'G13'))
plt.ylabel('Scores')
plt.yticks(np.arange(0, 81, 20))
Bottom = (52, 49, 48, 47, 44, 43, 41, 41, 40, 38, 36, 31, 29)
Center = (38, 40, 45, 42, 48, 51, 53, 54, 57, 59, 57, 64, 62)
Top = (10, 11, 7, 11, 8, 6, 6, 5, 3, 3, 7, 5, 9)
d = []
for i in range(0, len(Bottom)):
sum = Bottom[i] + Center[i]
d.append(sum)
width = 0.35 # 设置条形图一个长条的宽度
p1 = plt.bar(ind, Bottom, width, color='blue')
p2 = plt.bar(ind, Center, width, bottom=Bottom, color='green')
p3 = plt.bar(ind, Top, width, bottom=d, color='red')
plt.legend((p1[0], p2[0], p3[0]), ('Bottom', 'Center', 'Top'), loc=3)
plt.show()
if __name__ == '__main__':
draw_stacked_column_chart()
# -*- encoding: utf-8 -*-
# -----------------------------------------------------------------------------
# @File Name : html_to_pdf.py
# @Time : 2020/11/19 上午11:07
# @Author : X. Peng
# @Email : acepengxiong@163.com
# @Software : PyCharm
# -----------------------------------------------------------------------------
import pdfkit
def html_to_pdf():
options = {
'encoding': "utf-8",
# 'page-size': 'A5',
'page-width': '300mm',
'page-height': '[200mm,100mm,50mm]',
'margin-top': '0mm',
'margin-right': '0mm',
'margin-bottom': '0mm',
'margin-left': '0mm'
}
pdfkit.from_url('https://www.taobao.com', '/Users/pengxiong/Desktop/out.pdf', options=options)
if __name__ == '__main__':
html_to_pdf()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment