XlsxWriter chart without the Legend?

Question:

Hei! I want to make a cleaner look on a train analyze project.

Have this Excel speardsheet:Excel charts with explanation text box

I want to show the chart without the -Serie1 text box.

Some of the code in action:

df.to_excel(writer, sheet_name='Year_sheet', startrow=1, header=False, index=False)
workbook = writer.book
workbook = writer.book
worksheet1 = writer.sheets['Year_sheet']
chart_weight = workbook.add_chart({'type': 'line'})
chart_weight.add_series({'values': '=Year_sheet!$B$2:$B$13'})
chart_weight.set_x_axis({'name': 'Months'})
worksheet1.insert_chart('A16', chart_weight) 
chart_weight.set_title({'name': 'Gross tonnage'})
writer.save()

There will be severalcharts so it’s essential to save horisontal space an get rid the -Serie1 text on all charts. Hope you have some tips on how to solve this issue

Asked By: Jon Helge Einås

||

Answers:

According to the docs:

you should be able to remove the legend with this function :

chart.set_legend({'none': True})

or

chart.set_legend({'position': 'none'})
Answered By: titouanbou
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.