em0em7
em0em7

Reputation: 17

xlsxwriter chart with multiple categories

My excel chart has two index columns: 'Month' and 'Year'. How can I combine them in the python code below to achieve a graph that looks like the one below? To be specific, how do I specify the multiple categories?

chart.add_series({
    'categories': .............,
    'values': ['Sheet 1', 0, 1, 10, 1]
})

Excel graph I want to achieve

I already tried:

chart.add_series({
    'categories': [['Sheet1', 0, 0, 10, 0], ['Sheet1', 0, 1, 10, 1]]
    'values': ['Sheet1', 0, 2, 10, 2]
})

Upvotes: 2

Views: 1799

Answers (1)

jmcnamara
jmcnamara

Reputation: 41644

XlsxWriter supports clustered charts like this. See this example from the docs.

enter image description here

The main trick to get this to work is to specify the categories as 2D ranges (from column A to column B). This creates the clusters.

Upvotes: 2

Related Questions