Eliminate radar chart caption created with the openpyxl module in Python

Asked

Viewed 73 times

-1

would like to be able to delete the chart caption generated in excel by the Pyhton program using the openpyxl module below:

 from openpyxl import workbook
 from openpyxl import load_workbook
 from openpyxl import worksheet
 from openpyxl.chart import RadarChart, Reference

 wb = load_workbook(filename = 'grafico.xlsx')

 ws = wb.create_sheet('Grafico')

 rows = [
     ['Equipe', "Grau de Maturidade"],
     ['Equipe 1', 2.3,],
     ['Equipe 2', 3.4],
     ['Equipe 3', 4.2],
     ['Equipe 4', 2.1],
     ['Equipe 5', 3.8],
     ['Equipe 6', 2.8],
]

for row in rows:
ws.append(row)

chart = RadarChart()
chart.type = "marker"
labels = Reference(ws, min_col=1, min_row=1, max_row=7)
data = Reference(ws, min_col=2, max_col=7, min_row=1, max_row=7)
chart.add_data(data, titles_from_data=True)
chart.set_categories(labels)
chart.style = 26
chart.title = "Grau de Maturidade"
chart.y_axis.delete = False
chart.y_axis.scaling.min = 0
chart.y_axis.scaling.max = 5

ws.add_chart(chart, "A17")

wb.save(filename = 'grafico.xlsx')

I was able to find the parameters to define the position of the caption, but I could not delete the caption. For this my chart, it is unnecessary.

Another issue is also when I enlarge the chart size in excel, excel automatically adjusts the range of the y-axis guidelines and starts showing from 0.5 to 0.5, when I would like to keep from 1 point to 1 point.

inserir a descrição da imagem aqui Thank you!

  • As I am new here, I would like to understand why my question was classified as without research effort or unclear...

1 answer

0


The answers to my 2 problems are:

Delete the chart caption:

chart.legend = None

Keep axle grid lines at 1 in 1:

chart.y_axis.majorUnit = 1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.