79114513

Date: 2024-10-22 14:26:20
Score: 1
Natty:
Report link

Two options I have found that work for removing majorGridlines:

I.

chart_name.y_axis.majorGridlines = None

II.

from openpyxl.chart.axis import ChartLines
from openpyxl.chart.shapes import GraphicalProperties
from openpyxl.drawing.line import LineProperties

chart_name.y_axis.majorGridlines = ChartLines(GraphicalProperties(ln=LineProperties(noFill=True)))

The second option allows you to really fine tune your properties in the chart. There are a ton of options you can set by following the breadcrumbs. But this requires you to really dig into the documents.

https://openpyxl.readthedocs.io/en/stable/_modules/openpyxl/chart/axis.html#ChartLines

https://openpyxl.readthedocs.io/en/stable/_modules/openpyxl/chart/shapes.html#GraphicalProperties

https://openpyxl.readthedocs.io/en/stable/_modules/openpyxl/drawing/line.html#LineProperties

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Adam Kortis