Ich möchte ein Balkendiagramm mit x-Werten von 0-9 haben. Die Balken sollten den gleichen Abstand haben, und das Problem, das ich habe, ist die 10 Werte zusammenpassen, während alle den gleichen Bereich Platz für Bars haben.Matplotlib Balkendiagramm Achsenwerte
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(10, 6))
results_plot = plt.subplot2grid((10, 6), (0,0), colspan=8, rowspan=2)
results_plot.set_title("Results")
res_x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
res_y = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
rects = plt.bar(res_x, res_y, color='b')
results_plot.set_xbound(lower=0.0, upper=9.0)
results_plot.set_ybound(lower=0.0, upper=100.0)
results_plot2 = plt.subplot2grid((10, 6), (3,0), colspan=8, rowspan=2)
results_plot2.set_title("Results 2")
res_x2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
res_y2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
rects2 = plt.bar(res_x2, res_y2, color='b')
results_plot2.set_xbound(lower=-.5, upper=9.5)
results_plot2.set_ybound(lower=0.0, upper=100.0)
plt.show()
Also kurz gesagt mag ich alle x-Werte auf den Achsen sehen (wie in Abbildung 1) mit jeweils der gleichen Bar Raum (Abbildung 2).
genau das, was ich suchte, ty. – dtam