Categorical values on the x-axis with xlsxwriter
<p>I have a plot that needs names as the values for the x-axis. I imagine this is accomplished via the set_x_axis function for chart objects but can't find the proper key in the documentation (<a href="http://xlsxwriter.readthedocs.io/chart.html#set_x_axis" rel="nofollow">http://xlsxwriter.readthedocs.io/chart.html#set_x_axis</a>). The following code produces the graph below:</p>

<pre><code>chart = workbook.add_chart({'type':'scatter'})
colLetter = alphabet[1] #alphabet is list of alphabet
for ii in range(4):
    colLetter = alphabet[ii+1]
    chart.add_series({
        'name': '=Sheet1!$%s$1'%colLetter,
        'categories': '=Sheet1!$A$2:$A$'+str(lastRowNumber),
        'values': '=Sheet1!$%s$2:$%s$6'%(colLetter, colLetter),
    })
chart.set_title({'name': 'Cityblock'})
chart.set_x_axis({'name': 'Subject'})
chart.set_y_axis({'name': 'Distance'})
chart.set_style(11)
worksheet.insert_chart('F1', chart)
</code></pre>

<p><a href="http://i.stack.imgur.com/lH2om.png" rel="nofollow"><img src="http://i.stack.imgur.com/lH2om.png" alt="enter image description here"></a></p>

<p>Any suggestions? I'm using xlsxwriter with python 2.7.</p>

<p>Just set the series categories to point to the strings, or numbers, or dates that you wish to plot.</p>

<p>For example:</p>

<pre><code>import xlsxwriter

workbook = xlsxwriter.Workbook('chart.xlsx')
worksheet = workbook.add_worksheet()

# Add a column chart.
chart = workbook.add_chart({'type': 'column'})

# Write some data to add to plot on the chart.
worksheet.write_column('A1', ['Bob', 'Eve', 'Ann'])
worksheet.write_column('B1', [5, 10, 7])

# Configure the chart.
chart.add_series({'categories': '=Sheet1!$A$1:$A$3',
                  'values':     '=Sheet1!$B$1:$B$3'})

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

workbook.close()
</code></pre>

<p>Output:</p>

<p><a href="http://i.stack.imgur.com/fQQHo.png" rel="nofollow"><img src="http://i.stack.imgur.com/fQQHo.png" alt="enter image description here"></a></p>

python xlsxwriter