我用openpyxl创建了一个图表。一切都如预期的那样,但是我想在保持图表格式的同时隐藏图例中的数据点。简而言之,我想隐藏/删除图表右侧的所有数据点,同时保留条形图的颜色。
以下是用于构建图表的代码片段:
chart1 = BarChart()
series = chart1.series[0]
ndcs = Set()
scfs = Set()
for i, row in enumerate(results):
if 'DNDC' in row[0]: ndcs.add(i-1)
if 'DSCF' in row[0]: scfs.add(i-1)
for index in ndcs:
fill = PatternFillProperties(prst="pct5")
fill.background = ColorChoice(prstClr="red")
pt = DataPoint(idx=index)
pt.graphicalProperties.pattFill = fill
series.dPt.append(pt)
for index in scfs:
fill = PatternFillProperties(prst="pct5")
fill.background = ColorChoice(prstClr="blue")
pt = DataPoint(idx=index)
pt.graphicalProperties.pattFill = fill
series.dPt.append(pt)
FWIW,我试图按照文档here中的示例进行操作,但是我找不到任何关于隐藏图例信息的具体内容。在
我的问题是,在保留条形图颜色的同时,我需要关闭哪些成员/属性来隐藏图例上显示的数据点?在
我必须深入研究源代码,文档严重缺乏。在
尝试:
我想你需要设置
chart.legend.delete = True
相关问题 更多 >
编程相关推荐