python - Categorical values on the x-axis with xlsxwriter -


i have plot needs names values x-axis. imagine accomplished via set_x_axis function chart objects can't find proper key in documentation (http://xlsxwriter.readthedocs.io/chart.html#set_x_axis). following code produces graph below:

chart = workbook.add_chart({'type':'scatter'}) colletter = alphabet[1] #alphabet list of alphabet 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) 

enter image description here

any suggestions? i'm using xlsxwriter python 2.7.

just set series categories point strings, or numbers, or dates wish plot.

for example:

import xlsxwriter  workbook = xlsxwriter.workbook('chart.xlsx') worksheet = workbook.add_worksheet()  # add column chart. chart = workbook.add_chart({'type': 'column'})  # write data add plot on chart. worksheet.write_column('a1', ['bob', 'eve', 'ann']) worksheet.write_column('b1', [5, 10, 7])  # configure chart. chart.add_series({'categories': '=sheet1!$a$1:$a$3',                   'values':     '=sheet1!$b$1:$b$3'})  # insert chart worksheet. worksheet.insert_chart('d1', chart)  workbook.close() 

output:

enter image description here


Comments

Popular posts from this blog

php - isset function not working properly -

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -