Python Forum
How to set majorGridLines in openpyxl?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to set majorGridLines in openpyxl?
#1
Dear Experts,

Quite new at Python, so sorry fo stupid question but I have some experiences in C/C++ and Perl and some other languages. Now I need to come to Python...

I use openpyxl to read/write Excel files. To create a chart with logarithm scaled X-axis I need to switch on the majorGridlines. But I do not find any documentation about how to do this. All I found, that the value must be a type of <class ‘openpyxl.chart.axis.ChartLines’>.

# define chart
    chart = ScatterChart()
    chart.title = "FooBaa"
    chart.x_axis.title = "Frequency"
    chart.x_axis.scaling.logBase = 10
    chart.x_axis.scaling.min = 100 #Later dynmaic!
    chart.x_axis.scaling.max = 20000 #Later dynmaic!
    chart.x_axis.majorGridlines = ChartLines()
    chart.y_axis.title = "SPL"
    chart.legend = None
    
    # retrieve data
    x = Reference(ws1, min_col=3, min_row=1, max_row=staticlines)
    y = Reference(ws1, min_col=2, min_row=1, max_row=maxlines)
    s = Series(y, xvalues=x)
    chart.append(s)
Any tips or suggestions?
Thanks a lot for your help,
Karsten
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020