我正在创建一个图表,并希望在PowerPoint中打开图表之前切换已输入数据的行和列。序列的格式和分组不正确,图表以这种方式毫无意义。你知道吗
我使用的是元组,据我所知,元组很难操作,所以如果有一个命令我丢失了,只是切换行/列?这似乎是最简单的解决办法。你知道吗
x3 = Inches(0.3)
y3 = Inches(3.7)
cx3 = Inches(1.25)
cy3 = Inches(1.25)
chart_data_marriage = CategoryChartData()
chart_data_marriage.categories = ['Married HH', 'Married Footprint']
demographics['Profile List Title'] = demographics['Profile List Title'].str.strip()
tuple_married1 = demographics['Family Renters : Users/100 HHs']
tuple_married_footprint = demographics['Profile List: Total Profile Users/100 HHs']
tuple_married1.drop([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,38,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95], inplace = True)
tuple_married_footprint.drop([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,38,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95], inplace = True)
chart_data_marriage.add_series('Family Renters : Users/100 HHs', (tuple_married1))
chart_data_marriage.add_series('Profile List: Total Profile Users/100 HHs', (tuple_married_footprint))
marriagechart = storyboard1.shapes.add_chart(XL_CHART_TYPE.DOUGHNUT, x3, y3, cx3, cy3, chart_data_marriage).chart
marriagechart.has_legend = False
在tuple_married1
和tuple_married_footprint
中,我都有创建甜甜圈图表所需的数据,因此只需按正确的顺序格式化序列。同样,像现在PowerPoint中的按钮这样的切换行和列命令是理想的,否则可能需要更复杂的解决方案。你知道吗
如果数据来自Pandas数据帧,可以在将数据移到
pptx
之前执行demographics.T
。你知道吗python-pptx
没有“pivot chart data”行为,但它很简单,可以完成,而且是一个有趣的难题。你知道吗如果您以正确的形式插入值(与您输入ChartData的形式几乎相同),那么这样的操作应该可以实现,当然您可以调整它以适应:
相关问题 更多 >
编程相关推荐