我在这里分享了Excel表格: https://docs.google.com/spreadsheets/d/1WolE-TpyEXtv1rlr3xusESke46UMlRurAEH1D1Lsyss/edit?usp=sharing
我正在尝试创建工作进度图,这是我的代码:
import datetime
from datetime import date
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
df = pd.read_excel('Test Execution Progress.xlsx')
dp = df.groupby(by=['Project ID', 'Release Name', 'Cycle Name'],
as_index=False).plot(x=['Test Execution Date'],
y=['Planned', 'Commulative Tested', 'Commulative Passed'],
figsize=(16, 6), linestyle='dashed',marker='D', markersize=5,
title='Trest Exection Progress', legend=True, colormap='jet')
目标是:
对此方面的帮助表示高度赞赏。
修改 我从这里找到了一个例子: enter link description here
现在,我只需要:
答案 0 :(得分:0)
最后,我解决了所有问题,并设法获得所需的输出。这是代码:
grouped = dfm.groupby(by=['Project ID', 'Release Name', 'Cycle Name'], as_index=False)
# Calculate the height of table to be displayed above the Testing Progress charts
l = len(dfp['Cycle Name']) + 2
# Create a row_num variable for locating the charts in Excel sheet
row_num = l
# Create a for loop to create charts grouped
for name, group in grouped:
image_data = BytesIO()
fig = plt.figure(figsize=(12, 4), dpi=None, facecolor='white')
ax1 = fig.add_subplot(111, facecolor='aliceblue')
group.plot.line(ax=ax1, color='purple', x='Test Execution Date',
y='Planned', linestyle='dashdot', marker='o', markersize=5)
ax1.set_ylabel('Test Cases Count')
ax2 = ax1.twinx()
group.plot.line(ax=ax1,color='blue',x='Test Execution Date',
y='Commulative Tested', linestyle='dotted', marker='o', markersize=5)
# ax2.set_ylabel('Test Cases Count')
group.plot.line(ax=ax1, color='green', x='Test Execution Date',
y='Commulative Passed', linestyle='dashed' ,marker='o',markersize=5)
fig.suptitle('Overall Release Progress', fontsize=12, fontweight='bold', x=0.5, y =1.01)
plt.title(' => '.join([str(i) for i in name]), fontsize=10, loc='center')
ax1.grid(b=True, which='major', color='grey', linestyle='dotted')
plt.yticks([])
ax1.invert_yaxis()
fig.savefig( image_data, format="png", dpi=100, facecolor='aliceblue', bbox_inches='tight', pad_inches=0.4)
worksheet1.insert_image('A' + str(row_num), "", {'image_data': image_data})
row_num += 23
# Rearrange the sheets
sheet_names = ['Test Execution Progress', 'Test Execution by Date']
workbook.worksheets_objs.sort(key=lambda x: sheet_names.index(x.name))
# Save the workbook
writer.save()
这是输出:
注意:项目名称,版本名称和周期名称已被屏蔽。