0
votes

This is the sample code that I have to produce the chart (image linked below).

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)
value_axis.tick_label_position = XL_TICK_LABEL_POSITION.LOW

plot to remove axis line

2
A link-to-a-picture-only answer with no explananation nor code attempt is not recommended. - Ṃųỻịgǻňạcểơửṩ
i tried to change the color to white for it not to become visible. but should there be an another way? - mackinleyhills

2 Answers

2
votes

I believe this code will do what you're asking for:

chart.category_axis.visible = False
chart.value_axis.visible = False

If you want to hide the axis line but retain the tick-marks etc., try setting the width of the axis line to zero:

chart.category_axis.format.line.width = 0
0
votes

This doesn't remove the axis line, but makes it white, so it is also not visible anymore:

from pptx.dml.color import RGBColor

category_axis.format.line.color.rgb = RGBColor(255, 255, 255)