1

I wrote the code

chart2_values = Reference(sheet, min_col=6, min_row=1, max_col=10, max_row=13)
chart2_labels = Reference(sheet, min_col=5, min_row=2, max_row=3)
chart2 = BarChart(gapWidth=50,)
chart2.add_data(chart2_values, titles_from_data=True)
chart2.set_categories(chart2_labels)
chart2.title = "Ausgaben"
chart2.y_axis.scaling.orientation = "maxMin"
chart2.legend.position = "l"

chart2.style = 13
chart2.dataLabels = DataLabelList() 
chart2.dataLabels.showVal = True
chart2.height = 20 # default is 7.5
chart2.width = 50

sheet.add_chart(chart2, "K03")

to create a Bar Chart for my purposes. Now the labels are just in the middle over my BarCharts, which makes the whole thing a little bit confusing. See this Image where "January" and "February" are just right over the bars.

Is there a possibility, where I can set them below the bars or at the top of the whole graph?

Here is the Data for the Bar Plot

Cheers

Rafi

Rafii1
  • 29
  • 5
  • Can you please provide sample data so we can duplicate your issue? Have you seen [changing the layout](https://openpyxl.readthedocs.io/en/stable/charts/chart_layout.html) in the documentation? – APhillips Feb 07 '20 at 15:00
  • Hey, I added a picture so you can see the Data from Excel that I used for the bar Chart. I looked at every documentation I could find. – Rafii1 Feb 07 '20 at 16:06

1 Answers1

0

This is actually very easy to do, but I had to do some digging to find it:

chart2.x_axis.tickLblPos = "low" #this is actually at the top of the graph

Adding that to your code produces:

Excel Chart

APhillips
  • 1,175
  • 9
  • 17