python - python pptx 如何根据 XL_CHART_TYPE.LINE 更改图表中的线条格式
问题描述
如何根据 XL_CHART_TYPE.LINE 访问图表中系列的线格式对象?
chart_data = ChartData()
vec2 = [ float(i.value) for i in xl_sheet.col(1)]
chart_data.categories = [ datetime.datetime.fromordinal(int(693594+i.value )) for i in xl_sheet.col(0)]
uu=chart_data.add_series('Model1', tuple(vec2))
我没有访问系列行的格式
uu.format.line.color.rgb = RGBColor((100,100,100))
解决方案
创建图表后,您可以通过线代表的系列访问每条线:
graphic_frame = slide.shapes.add_chart(..chart_data,..)
# ---graphic frame is the shape containing the chart, not the chart itself---
chart = graphic_frame.chart
# ---get the desired series from the chart---
series = chart.series[0]
# ---series.format is a ChartFormat object, which in turn provides access to
# the LineFormat object for that series---
line = series.format.line
# ---change the line style, color, etc. the same way as for any other line---
line.color.rgb = RGBColor(255, 0, 0)
推荐阅读
- javascript - 带去抖动的 useEffect
- .htaccess - 如何在传递 GET 参数时重定向路径而不更改 URL?
- winapi - 找不到“wincontypes”
- mysql - 在 Eclipse 上启动 Spring Boot MySql 应用程序时出错
- django - 如何使用 Django 模型在 PostgreSQL 中保存文本数组。?
- ruby - 红宝石地图,地图!修改哈希数组
- python - 全文匹配的各种搜索算法和性能
- xpath - 我应该使用什么 XPath 表达式来获取 YouTube 视频的点赞数和评论数?
- python - 如何使用 for 循环创建 Numpy 矩阵?
- php - 如何自动:在“plugins_loaded”操作之后通过插件设置的 WordPress 永久链接设置