軸の最大/最小値の設定

2014/12/22

Python2.7.6, XlsxWriter 0.6.4

chart.set_x_axis({
    'min': 0,
    'max': 10,
    })
chart.set_y_axis({
    'min':0,
    'max':20
    })

全体

# -*- coding: utf-8 -*-

import xlsxwriter

def main():

    workbook = xlsxwriter.Workbook("test.xlsx")
    worksheet = workbook.add_worksheet()

    write_sample_data(worksheet)

    # Create Chart
    chart = workbook.add_chart({'type': 'scatter',
                                 'subtype': 'straight_with_markers'})

    chart.add_series({
        'name':       '=Sheet1!$B$1',
        'categories': '=Sheet1!$A$2:$A$7',
        'values':     '=Sheet1!$B$2:$B$7',
    })

    chart.set_x_axis({
        'min': 0,
        'max': 10,
            })
    chart.set_y_axis({
        'min':0,
        'max':20
        })

    # Insert the chart into the worksheet
    worksheet.insert_chart('A9', chart)

    workbook.close()

def write_sample_data(worksheet):
    data = [ [  0,   0,   0],
             [0.5, 2.3, 4.2],
             [1.2, 4.2, 5.6],
             [2.1, 5.6, 7.8],
             [3.6, 7.4, 9.3],
             [4.9, 7.9, 14.2] ]

    worksheet.write(0,1,"TEST1")
    worksheet.write(0,2,"TEST2")
    for line in data:
        for value in line:
            row = data.index(line)+1
            col = line.index(value)
            worksheet.write(row,col,value)

if __name__ == '__main__':
    main()

examples/ including datetime in axis 'max' and 'min'
https://github.com/jmcnamara/XlsxWriter/issues/73