这是我必须生成图表的示例代码(下面的图像链接)。
x, y, cx, cy = Inches(2), Inches(2), Inches(6), Inches(4.5)
graphic_frame = slide.shapes.add_chart(
XL_CHART_TYPE.BAR_CLUSTERED, x, y, cx, cy, chart_data
)
chart = graphic_frame.chart
chart.chart_title.has_text_frame=True
chart.chart_title.text_frame.text= "1_TRS_Year"
chart.chart_style = 1
plot = chart.plots[0]
plot.has_data_labels = True
data_labels = plot.data_labels
data_labels.font.size = Pt(9)
data_labels.font.color.rgb = RGBColor(0,0,0)
data_labels.number_format = '0%'
data_labels.position = XL_LABEL_POSITION.OUTSIDE_END
category_axis.has_major_gridlines = False
category_axis.has_minor_gridlines = False
category_axis.minor_tick_mark = XL_TICK_MARK.OUTSIDE
category_axis.tick_labels.font.italic = False
category_axis.tick_labels.font.size = Pt(12)
category_axis.tick_label_position = XL_TICK_LABEL_POSITION.LOW
value_axis = chart.value_axis
value_axis.has_major_gridlines = False
value_axis.has_minor_gridlines = False
value_axis.minor_tick_mark = XL_TICK_MARK.OUTSIDE
value_axis.tick_labels.font.italic = False
value_axis.tick_labels.font.size = Pt(12)
答案 0 :(得分:0)
我相信这段代码将满足您的要求:
chart.category_axis.visible = False
chart.value_axis.visible = False
如果要隐藏轴线但保留刻度线等,请尝试将轴线的宽度设置为零:
chart.category_axis.format.line.width = 0